The data in mongodb is like this
{
"_id": "1",
"a": { ... },
"b": { ... },
"c": [ ... ],
"d": [ ... ]
}
I can update the document using a single “$set” operator.
db.collection.update({"_id": "1"}, {
"$set": {
"a": { new dict },
"b": { new dict },
"c": [ new list ],
"d": [ new list ]
}
})
I can also update the document using multiple “$set” (each field has a “$set”).
db.collection.update({"_id": "1"}, [
{
"$set": { "a": { new dict } }
},
{
"$set": { "b": { new dict } }
},
{
"$set": { "c": [ new list ] }
},
{
"$set": { "d": [ new list ] }
}
])
I would like to learn if there are any performance concerns on the mongodb end by using the “multi-set” version. Is it Ok to use the “multi-set” version if, for some cases, I need to.