This package has been deprecated

Author message:

No longer maintained

mong

2.0.2 • Public • Published

mong

NPM Version Build Status Coverage Status NPM Downloads License

Simple models for mongodb objects.

npm install mong

Creating a collection class

var db = require('mong').create();
 
var User = module.exports = db.model('users');
 
User.prototype.getFullName = function () {
  return this.firstName + ' ' + this.lastName;
};
 

Then you can use the model:

db.connect('mongodb://localhost/mydatabase', function (err) {
  if (err) throw err;
 
  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!');
  });
});

Package Sidebar

Install

npm i mong

Weekly Downloads

14

Version

2.0.2

License

MIT

Last publish

Collaborators

  • aantthony