0.4.1 • Published 9 years ago

modm v0.4.1

Weekly downloads
83
License
THE BEER-WARE LIC...
Repository
github
Last release
9 years ago

MODM

Mongodb Object Document Mapper

Example

var modm = require("modm");

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

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

// get a collection
var 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

License

"THE BEER-WARE LICENSE" (Revision 42):

adrian@ottiker.com wrote this code. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.

0.4.1

9 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.9

10 years ago

0.2.8

10 years ago

0.2.7

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.9

11 years ago

0.1.8

11 years ago

0.1.7

11 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago