0.1.19 • Published 11 years ago

mongoose-subpopulate v0.1.19

Weekly downloads
1
License
-
Repository
github
Last release
11 years ago

Mongoose Subpopulate

Mongoose-subpopulate was created for my needs on SpanDeX.io. It's monkey-patch of the populate Mongoose library for using MongoDB in Node.js apps. Subpopulate allows you to nest populate calls.

It allows you to do this:

m.User.find({}).populate('best_friend').populate('best_friend.best_friend').exec(function (err, result) {
    console.log('My BFF\'s BFF: ', result.best_friend.best_friend.username);
});

Mongoose-subpopulate also allows you to ignore "err" in your callbacks:

m.User.find({}).populate('best_friend').populate('best_friend.best_friend').exec(function (result) {
    console.log('My BFF\'s BFF: ', result.best_friend.best_friend.username);
});

... and if you don't handle the errors, Mongoose-subpopulate will. Use a global exception handler like webkit-devtools-agent if you plan to do this.

Mongoose-subpopulate also handles ObjectIDs better than vanilla mongoose, and allows you to save a sub-object to another object without fear of it being cast to an ObjectId, as with vanilla Mongoose.

Currently Mongoose-subpopulate is only working with Mongoose 2.7 (untested in Mongoose 3 because I haven't upgraded yet). If you need to use Mongoose 3, please fork, fix, and send me a pull request.

Installation

You know the drill:

npm install mongoose-subpopulate

Look at example.js to see how I use mongoose-subpopulate.

0.1.19

11 years ago

0.1.18

11 years ago

0.1.17

11 years ago

0.1.16

11 years ago

0.1.15

11 years ago

0.1.14

11 years ago

0.1.13

11 years ago

0.1.12

12 years ago

0.1.11

12 years ago

0.1.10

12 years ago

0.1.9

12 years ago

0.1.8

12 years ago

0.1.7

12 years ago

0.1.6

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago

0.0.7

12 years ago

0.0.6

12 years ago

0.0.5

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago