javascript - Mongoosejs: how to pass node validator object to the callback function of a query -
i'm struggling while trying pass variables/functions mongoose query callback function.
what i'm trying is: edit: title changed , illustration redefined
validator.protoptype.customcheck = function(model, path) { var self = // validator object {msg: 'msg', error: ...}; model.find({name: 'john'}, function(err, res) { if (res.length === 0) { self.error( self.msg ) // msg hasn't expected value. // have other validators after callback gets executed // context different. don't know how pass right context } else { // else ... } } }
javascript mongoose
No comments:
Post a Comment