I am trying to update the mongodb embedded collection using the $ positional operator from ruby mongoid, but it is not working. Below the mongoid query
Viewcounter.collection.update({:item_id=>BSON::ObjectId('yyyy'),'viewinfos.remote_ip' => 'xxxx'},{'$inc' => {'viewinfos.$.viewcount' => 1}})
After some more digging i found that no mongodb queries works with mongoid update.including below simple query
Item.collection.update({'_id' =>BSON::ObjectId('sss')},{:isused => false})
has anyone got a better way of doing the positional operator queries with mongoid?
EDIT
But as per the mongodb official ruby driver documentation, this should work. below the excerpt
coll.update({"_id" => doc["_id"]}, {"$set" => {"name" => "MongoDB Ruby"}})