mongoid/mongoid — Issue #1494: $inc does not work on hash type fields
Author: rurounijones
Created: 2011-12-13 07:21:55+00:00
State: open

$inc (and potentiall other atomic operators but I haven't tested) do not currently work on anything but top level fields.

Assuming I Have a field 'users' with the :type => Hash I would like to be able to do the following

a = Account.first
a.inc('users.accessed')

Which would create a hash key 'accessed' and set it to 1 if it does not yet exist or increment it if it does not exist. Currently inc('users.accessed') literally creates a field called 'users.accessed'

As before, if someone can point me to roughly the right place to start at I can have a go at doing this myself.