Where has findAndModify gone?

if (Meteor.isServer) {
db.counts.findAndModify = db.counts.rawCollection().findAndModify.bind(db.counts.rawCollection());
db.counts.update = db.counts.rawCollection().update.bind(db.counts.rawCollection());
db.counts.remove = db.counts.rawCollection().remove.bind(db.counts.rawCollection());

Hi all,
I have the above code in my app header. THe findAndModify operation definition says it “findAndModify” does not exist??? The other two are ok…

Did something happen in mongo? Or am I throughly confused? Or…


Hi @greg0owens . If you are using Meteor 2.6 or higher then the Node Mongo Driver version is 4.3.1. The documentation of Collection methods (what .rawCollection provides) for that driver version are here. .findOneAndUpdate may do what you want.

.findAndModify was marked as deprecated in Node Mongo 3.x and removed in 4.x. Meteor upgraded to Node Mongo 4.x with the release of Meteor 2.6.


thanks so much. Will rebuild this piece with findOneAndUpdate

It literally went in the history of development.