Method: Mongoid::Relations::CounterCache::ClassMethods#update_counters
- Defined in:
- lib/mongoid/relations/counter_cache.rb
#update_counters(id, counters) ⇒ Object
Update the given counters by the value factor. It uses the atomic $inc command.
42 43 44 45 46 |
# File 'lib/mongoid/relations/counter_cache.rb', line 42 def update_counters(id, counters) counters.map do |key, value| where(:_id => id).inc(key, value) end end |