mongoose-ref-promises
A mongoose plugin which adds promise-based population virtual properties to your Models
Installation
Install the module with: npm install mongoose-ref-promises
Use it by adding it as a plugin to any mongoose.Schema
// [...]var refPromises = ;UserSchema;// [...]
Examples
The plugin adds virtual properties to each 'ref' property in your schema.
Say we have this setup.
var mongoose = Schema = mongooseSchema ObjectId = SchemaObjectId; var refPromises = ; var UserSchema = friends: type: ObjectId ref: 'User' bff: type: ObjectId ref: 'User' ;UserSchema; var User = mongoose;
We can than access the virtual properties friendsP
and bffP
of any
'User' document.
i.e.
// [...]userfriendsP ;
or
// [...]userbffP ;
License
Copyright (c) 2014 Pedro Yamada. Licensed under the MIT license.