mongomodel
Simple models for mongodb objects.
npm install mong
.
Creating a collection class
var db = require('mong').create('mongodb://localhost/mydatabase');
var User = module.exports = db.model('users');
User.prototype.getFullName = function () {
return this.firstName + ' ' + this.lastName;
};
Then you can use the model like so:
User.findOne({firstName: 'Anthony'}, function (err, doc) {
console.log(doc.getFullName());
doc.update({$inc: {count: 1}});
});
User
.find()
.on('data', function (user) {
console.log(user.getFullName());
})
.on('end', function () {
console.log('Node streams are cool!');
});
![Coverage Status](https://coveralls.io/repos/aantthony/mong/badge.png?branch=master)