tags:

views:

97

answers:

2

I have the following object

   {
        "_id" : ObjectId("4b8699aa3b97dc29dd000000"),
        "name" : "test",
        "email" : "test",
        "url" : "test",
        "items" : [
                {
                        "$ref" : "item",
                        "$id" : ObjectId("4b866a043b97dc22a9000001")
                }
        ]}

How can I remove the reference from items? I have the objectid for the reference? I tried the following, which does work for normal list items but not with a reference.

db.foo.update(foo, {$pull: {'items': {'$id': ObjectId("4b866a043b97dc22a9000001") } } })
A: 

try this:

db.foo.update(foo, {$pull: {'items': {'$id': new ObjectId("4b866a043b97dc22a9000001") } } })
luckytaxi
A: 

The problem was the version. In the old version you have to give all the keys and values to pull. After updating to version 1.3.2 this was not necessary and the code worked.

swoei