mongodb - Trigger middleware on mass operations in Mongoose -
based on documentation mongoose seems middleware triggered operations on models, i.e. not communicate database directly. means if wanted trigger middleware mass removal, example, i'd have do:
users.find().exec(function (err, users) { users.foreach(function (user) { user.remove(); }); });
is there better way perform mass operations on models in mongoose still triggers middleware?
Comments
Post a Comment