MongoDB positional operator issue

95 Views Asked by At

I am trying to run the following update command with a positional operator.

businesses.update({ '_acl.5370b9af4a6b2a941ad3bf5e': 'read', 
'rooms._id': ObjectId("5370c1ca19b56d0200b26e7f"), 
_id: ObjectId("5370b9af4a6b2a941ad3bf58") }, 
{ '$set': { 'rooms.$.lastServiced': new Date("Thu, 15 May 2014 16:17:28 GMT") } } )

The query has 2 arrays, _acl.5370b9af4a6b2a941ad3bf5e and rooms. I want to update the rooms array using positional operator but my update goes to the wrong element in the rooms array.

This problem goes away if I remove this '_acl.5370b9af4a6b2a941ad3bf5e': 'read' part from the query.

I think that mongodb uses the position from the _acl array even though in the $set part I am using rooms array. Is this a bug in mongodb?

0

There are 0 best solutions below