Socket
Socket
Sign inDemoInstall

mong

Package Overview
Dependencies
17
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mong

Lightweight models for mongodb objects


Version published
Weekly downloads
14
increased by40%
Maintainers
1
Install size
2.98 MB
Created
Weekly downloads
 

Readme

Source

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!');
  });
});

Keywords

FAQs

Last updated on 18 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc