README
nonrenew-nonrel-wrapper
Not Only Relational Databases Wrapper (nonrel) is a database wrapper to made easy the CRUD operations.
Example
var User = new Collection({
name: "users",
fields: {
"id":{required:true},
"username":{required:true},
"password":{required:true},
"first_name":{required:false},
"last_name":{required:false}
}
});
var Posts = new Collection({
name: "users",
fields: {
"id":{required:true},
"user":{required:true},
"title":{required:true},
"content":{required:false},
"tags":{required:false}
}
});
var dbw = new DataBaseWrapper({
collections: [User, Posts],
connect: function(){
// connectiong actions
this.connection = ... // <= this context is common for all methods
},
select: function(collection, filters, callback){
},
upsert: function(collection, filters, callback){
},
delete: function(collection, filters, callback){
}
});
dbw.connect();
var crypto = require('crypto');
var shasum = crypto.createHash('sha1');
shasum.update("mypasswd");
dbw.select(Users,
{
"username":"jdoe",
"password":shasum.digest("hex")
},
function (err, rows) {
if (err) {
// do anything if an error exists
} else {
// do anything if no error
}
}
);