Rahul Desai
Rahul Desai

Reputation: 15501

Mongo record not updating, no error either

Here is the record that I want to update:

{
    "_id" : ObjectId("519177384e2e9fee10000000"),
    "fb_id" : { "0" : "2000" },
    "name" : { "0" : "Aaa Bbb" },
    "email" : { "0" : "[email protected]" }
}

I would like to fb_id to be changed to "2000", instead of { "0" : "2000" }.

I tried..

PRIMARY> db.users.update({fb_id : "{ 0 : 2000 }"},{$set: {fb_id: "2000"}});

It did not work but it did not through any error either. What exactly am I doing wrong?

Upvotes: 1

Views: 488

Answers (1)

assylias
assylias

Reputation: 328649

You probably just need to move the double quotes:

db.users.update({fb_id : { "0" : "2000" }},{$set: {fb_id: "2000"}})

Upvotes: 2

Related Questions