I have the following document structure:
{
...
timings: {
mon: "",
tue: "",
wed: "",
thu: "",
fri: "",
sat: "",
sun: "",
}
...
}
I want to set the value "Open 24 Hours" for all the days of the week.
Currently I am using the query:
db.collection.update({_id: ObjectId("someId")}, {$set: {"timings.mon": "Open 24 Hours"}});
And then running the same for the rest of the days of the week.
I can also set all the fields in the same query explicitly, but it's faster to just change the day and run it again.
Is there a way to set the value of multiple fields in a subdocument in a more efficient way?
UPDATE
I tried the following query, but it doesn't work:
db.collection.update({_id: ObjectId("someId")}, {$set: {"timings.$": "Open 24 Hours"}});