I have this structure in collection. i want to update "remark" to "Better" if "language" is "english".
{"Information":[{"id":"5245","details":[{"language":"english","remark":"good","status":"published"},{"language":"hindi","remark":"good","status":"published"},{"language":"arabic","remark":"good","status":"published"}]}],"name":"saroj","company":"visa"}
i am able to get the particular section of data from db based on language
db.getCollection("containts").aggregate([
// Filter possible documents
{ "$match": {"$and": [{ "Information.id": "1" },{ "name": "saroj" }]}},
// Unwind the array to denormalize
{ "$unwind": "Information" },
{ "$unwind": "Information.details" },
// Match specific array elements
{ "$match": { "Information.detail.language": "english" } },
// Group back to array form
{ "$group": {
"_id": "$_id",
"details": { "$push": "Information.details" }
}}])
Output:
{ "details": [{
"language": "english",
"remark": "good",
"status": "published"
}]}
But i am unable to update "remark" based on "language"