These are chat archives for LearnBoost/mongoose

30th
Jan 2015
Meistercoach83
@Meistercoach83
Jan 30 2015 21:05
Hey there! I´d like to auto-populate my referenced data. Can I add a function to my Schema to do that for me?
Valeri Karpov
@vkarpov15
Jan 30 2015 22:37
@Meistercoach83 4.0.0-rc0 was just released today, it includes hooks for queries. You can do something like schema.pre('findOne', function() { this.populate('pathToPopulate'); });. See tests for an example: https://github.com/LearnBoost/mongoose/blob/d2325994e4e902a5b7932506d462e556cdfbf691/test/query.middleware.test.js#L158-172