2

Is it possible to FindAndModify in MongoDB and increment a DateTime field? If so, is it also possible to use FindAndModify to increment a DateTime field by the value of another TimeSpan property?

I know I can query the objects out, update the property for each object and then one by one save them back, but that's slow, especially for large result sets.

jjxtra
  • 20,415
  • 16
  • 100
  • 140
  • I haven't worked on mongodb. However, looking at the doc I suppose [this](http://docs.mongodb.org/manual/reference/method/db.collection.update/#example-update-multi) is what you are looking for? – shahkalpesh Jul 07 '14 at 05:55
  • Doesn't look like it unfortunately. No worries though I think I have a work around. – jjxtra Jul 07 '14 at 22:48
  • possible duplicate of [Update a value in MongoDB based on its current value](http://stackoverflow.com/questions/2480030/update-a-value-in-mongodb-based-on-its-current-value) – Neil Lunn Jul 08 '14 at 02:57
  • I ended up using a locking document in another collection. – jjxtra Jul 15 '14 at 06:00

0 Answers0