I have a document with following structure. I want to insert a new file in the array files followed by making all other file status set to "INACTIVE". After inserting, I am trying following code to update other file of the array but it is unable to match.
{
{
"id":"fafsahjaf867rwhrbjw",
"files" : [
{"name": "123", status:"ACTIVE"},
{"name": "124", status:"ACTIVE"},
{"name": "125", status:"ACTIVE"},
{"name": "126", status:"ACTIVE"},
]
},
}
query = bson.M{ "id": productId,
"files": bson.M{
"$not": bson.M{"$elemMatch": fileObj}}}
update = bson.M{
"$set": bson.M{
"files.$.status": "INACTIVE",
},
}