These are chat archives for LearnBoost/mongoose

26th
Feb 2015
Alex
@whitecolor
Feb 26 2015 07:11
@vkarpov15 in terms of autopopulate what do you think about virtual async properties? Or maybe this could be impemented using some kind of after select hook.
Valeri Karpov
@vkarpov15
Feb 26 2015 14:57
async virtuals? That's something much more fundamental, virtuals are sync by design so you can use assignment operator. Also there's really no after select hook - query middleware only works for these methods: https://github.com/LearnBoost/mongoose/blob/master/lib/schema.js#L11-17 and only when the operation is actually executed. For instance, MyModel.find({ test: 1 }).count(callback); will execute count middleware but not find, because the actual operation sent to the server is a count
Alex
@whitecolor
Feb 26 2015 15:03
@vkarpov15 well so there are post and pre query hooks available for use? I haven't seen this in docs.
Alex
@whitecolor
Feb 26 2015 15:17
and post hooks are not async actually as I see from the code
Yann 'Aaunel' Eves-Hollis
@aaunel
Feb 26 2015 22:39
@vkarpov15 that's what I thought, I've edited the original StackOverflow thread to show the steps to replicate saving {} as an ObjectId