Mongo plugin for modella. Uses learnboost/monk for a clean mongo driver.
npm install modella-mongo
var model = require('modella');
mongo = require('modella-mongo')('localhost/db');
var User = model('user')
.attr('_id')
.attr('name')
.attr('email')
.attr('password');
User.use(mongo);
/**
* Initialize
*/
var user = new User;
user.name('matt')
.email('mattmuelle@gmail.com')
.password('test');
user.save(function(err) {
console.log(user.toJSON());
});
By loading this plugin, model inherits:
Index an attribute in mongo.
User.index('email', { unique : true });
MIT