Meteor Mongo does not have findAndModify support - how to generate atomic counters?

As per this Github issue:

Meteor does not or intend to add support for findAndModify, which is the method required to genenrate atomic counters, as per:

How do I get around this?

As long as you only need it in server code, you can do it like this:

Thanks Rob. I mananged to find a package that does this for me:

https://atmospherejs.com/fongandrew/find-and-modify

2 Likes

Unfortunatly this package does not work after upgrading to 1.4.1

Has anyone found a package that works with 1.4.1?

Edit: Have looked into the new return value from the node mongo drivers and the desired result is now under .value field. There’s an open PR to keep the package updated but for now you can read from that value if you are in a hurry.

1 Like

Yes, I had the same problem and that is the solution.