Reputation: 645
I would like to run an update command to mongodb that will update all the info inside of an collection. in mysql i will just do :
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
How can I achive this in mongodb? so far this is what I have :
db.property.update(
{
$set: {"image":{"isHosted": false, "imageUrl": "", "imageMediumUrl": "", "imageThumbUrl": ""}}
}
)
This is what my current property looks:
{
"_id": ObjectId("54183b8ee8643951f6b3ee0f"),
"image": "http: \/\/img.com\/California\/Properties\/JPG_Main\/341\/3513341.jpg",
}
Thanks in advance, hope someone can help me as a newbie with mongodb
Upvotes: 0
Views: 43
Reputation: 1332
You're missing a clause to your set statement. You need the equivalent of the where clause.
IE:
db.property.update( { image: "http:\/\/img.com\/California\/Properties\/JPG_Main\/341\/3513341.jpg"},
{
$set: {"image":{"isHosted": false, "imageUrl": "", "imageMediumUrl": "", "imageThumbUrl": ""}}
}
)
Upvotes: 1