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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -