I am trying to update multiple records in mongodb. single Record is as follows:
"_id" : ObjectId("59704fac4ed2aa47e68c7f50"),
"uid" : 157140,
"ts" : NumberLong("170720120636"),
"a" : {
"em" : "email20788@pragatee.com",
"fk" : "email20788@pragatee.com",
"mo" : "1248849893",
"d" : 0,
"bl" : 0,
"att3" : "city20788",
"att66" : "fname20788"
}
}
{
"_id" : ObjectId("59704fac4ed2aa47e68c7f51"),
"uid" : 157141,
"ts" : NumberLong("170720120636"),
"a" : {
"em" : "email20789@pragatee.com",
"fk" : "email20789@pragatee.com",
"mo" : "1248849920",
"d" : 0,
"bl" : 0,
"att3" : "city20789",
"att66" : "fname20789"
}
}
i wanted to update value of array "a.d" for certain records.
Query which i am trying:
db.userDetails.find({ uid : {$in : [157140,157141]}}).update({$set: {"a.d":1}})
but i am getting error:
"errmsg" : "A single update on a sharded collection must contain an exact match on _id (and have the collection default collation) or contain the shard key (and have the simple collation). Update request: { q: { uid: { $in: [ 157140.0, 157141.0 ] } }, u: { $set: { a.d: 1.0 } }, multi: false, upsert: false }, shard key pattern: { uid: 1 }"