I am trying to use the new unstable version of mongoose> 4.0.0 to check for update requests.
say i want to update the circuit using the following query
schema.update({_id:'blah'},{a:'blah'},function(err){
so let's say that I have the following diagram,
var schema = new Schema({ a:{type:String} }); schema.pre('update',function(next){ var findQuery=this._conditions;
How do I get the update request {set: {a: 'blah'}} in the middleware so that I can perform some checks before performing the update?
As an alternative, I know that an update request can be obtained in middleware, in
schema.post('update',function(){ var findQuery=this._conditions;
but it's too late, I need this in the preliminary middleware to check before actually updating the db.
I tried to view the middleware 'this' object, but cannot find the updateQuery object anywhere and this._update undefined in the middleware.
Is there any way to do this? thanks
source share