Socket
Socket
Sign inDemoInstall

modm

Package Overview
Dependencies
1
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    modm

A MongoDB Object Document Mapper (ODM)


Version published
Weekly downloads
5
decreased by-72.22%
Maintainers
1
Install size
3.05 MB
Created
Weekly downloads
 

Readme

Source

MODM

Mongodb Object Document Mapper

####Example var modm = require('modm');

// define a schema
schema = new modm.Schema({field: String});

// create db connection
model = modm('myDb', {
    host: '127.0.0.1',
    port: 27017,
    server: {pooSize: 5},
    db: {w: 1}
});

// get a collection
myCollection = model('myCollection', schema);

// db operations
myCollection.insert({data: 1}, function (err, item) {
   //... 
});

// connect first, otherwise find will return undefined
// instead of a cursor.
model.connect(function (err, db) {
    var cursor = myCollection.find({/*query*/});
    cursor.toArray(function () {
        //...
    });
});

// ..or access the cursor in the callback
myCollection.find({/*query*/}, function (err, cursor) {
    cursor.toArray(function () {
        //...
    });
});

####Info Results of atomic operations are not validated.

####Schema options type: String, // Array | Boolean | Buffer | Date | Number | Object | ObjectID required: true, // false default: 'default' // default value validate: function () {}, // email, url, ... manipulate: function () {}, pre: 'pre', // "string" post: 'post', // "string" charStyle: 'normal', // uppercase | lowercase trim: true, // false maxLength: 5, // integer minLength: 1, // integer max: 5, // number min: -3, // number

// not yet implemented..
live: true // false

Keywords

FAQs

Last updated on 24 Jul 2013

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