Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I use other than .findAndModify?

Tags:

meteor

I have the following code:

var roomDoc = Rooms.findAndModify({
  query: {name: roomName},
  update: {$setOnInsert: {unixTimestamp: unixTimestampSeconds()}},
  new: true,
  upsert: true
});

After getting an error that .findAndModify is undefined, I realized, Meteor doesn't implement .findAndModify.

Is there a Meteor way to achieve similar functionality by using different queries?

like image 507
Blaine Lafreniere Avatar asked Dec 24 '22 21:12

Blaine Lafreniere


1 Answers

However the answer above explains this specific case, in many other cases it is supposed that findAndModify is an atomic operation that could be used for example to generate unique IDs:

http://docs.mongodb.org/v3.0/tutorial/create-an-auto-incrementing-field/

It seems that Meteor won't implement a wrapper of findAndModify as a corresponding ticket is already closed, however the community proposed several solutions that already work on both server and client sides:

https://github.com/meteor/meteor/issues/1070

like image 108
romaroma Avatar answered Jan 21 '23 01:01

romaroma