Created
May 23, 2014 21:18
-
-
Save percyperez/034a2c2ca66603fcf67e to your computer and use it in GitHub Desktop.
Get populated data from subdocument excluding specific fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var populate_data_from = 'trainers tags', | |
video_data = { | |
path: 'videos', | |
model: 'Video', | |
select: 'title description legacy_video videofiles.sources.10' | |
}, | |
excludes = '-royalties'; | |
/** | |
* @return {object} A single collection with videos, tags and trainers | |
* populated based on a partnumber | |
*/ | |
VideoCollection.statics.FindByPartNumber = function(partnumber, callback) { | |
this.findOne({'partnumber': partnumber}).select(excludes).populate(populate_data_from).populate(video_data).exec(callback); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment