How to increment integer field in atomic manner? Can FindAndModify method helps?
For example document contains field count and I wanna to increment it without retrieving full document and saving back.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I did leave a comment but I found it. The
$incmodifier will increment a field internally. Completely atomically for this exact purpose.See here “Monog DB Atomic Operations”