I am using async.parallel to run 2 functions at once, which are run from a static function on a mongoose model. As you can see, I can this this
to access the model and it's functions in this code (the model has a static function called verifyParent):
async.parallel([
async.apply(content, {slug: slug}),
async.apply(this.verifyParent, req.body.reply),
], (err, result) => {
//results
});
But in the this.verifyParent function, if I try to use this
, it's equal to my express app, and not the mongoose model. I beleive async.apply is doing this, and I can't figure out how to make it keep the this
value it would normally have.
In verifyParent, I'm trying to query mongodb. When I run this.findOne()
, it says it's not a function, and looking at this seems to indicate it's set the app, not to the model.