Why do we still have to manually hack in a way to atomically find and update multiple documents? http://stackoverflow.com/questions/7334390/has-mongoose-support-findandmodify-mongodb-method
(here's the relevant code)
Counters.statics.findAndModify = function (query, sort, doc, options, callback) {
return this.collection.findAndModify(query, sort, doc, options, callback);
};
why is this closed, or what is the recommended way to update multiple documents at once and get the list of matched docs (or at least their _id
s)? Is it still by using Model#collection.findAndModify(...)
?
@huafu not possible with findAndModify: https://docs.mongodb.com/manual/reference/method/db.collection.findAndModify/ . You'd need to do updateMany()
, that gives you back the list of ids.