Atomic increment in Mongoid
If you have to increment a value via Mongoid, simply go for the Model#inc
method:
person.inc(:age, 1)
See other atomic operations on the official doc.
Written by Emmanuel Turlay
Related protips
1 Response
That is very helpful, is there a method to decrement too? - I can't seem to find out.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#