i know, there is no transaction support on mongo DB. But now i need to read an value of an document, increment by 1 and write the new value.
Or – different way:
Update an element and read the value at the same time.
For this i like to use find and modify : http://www.mongodb.org/display/DOCS/findAndModify+Command
this command updates an document and returns the value before updating.
Is this happens in on (same like) transaction?
The point is: is it possible that an other session updates the same value between the two steps of the other session?
(sorry, for me it’s hard to explain – i hope you understand what i’m trying to say)
thank you.
findAndModifycommand is atomic. Which means that no other operation can happen betweenfindandmodifyparts. This command was made exactly for things like incrementing counters/settings flags and reading them at the same time.