I'm currently facing a challenge in figuring out how to locate a specific document within a collection, and then pinpoint a value within an object nestled in a subarray of that document — subsequently altering a value within that object.
My objectives are as follows:
Locate by _id
Identify the object in the ratings array that corresponds to the user + post keys
Modify the report value within that object
To provide context, the structure of the documents in my collection is outlined below.
{
"_id" : "mz32AcxhgBLoviRWs",
"ratings" : [
{
"user" : "mz32AcxhgBLoviRWs",
"post" : "SMbR6s6SaSfsFn5Bv",
"postTitle" : "fdsfasdf",
"date" : "2017-09-27",
"rating" : "4",
"review" : "sdfa",
"report" : "a report"
},
{
"user" : "mz32AcxhgBLoviRWs",
"post" : "iZbjMCFR3cDNMo57W",
"postTitle" : "today",
"date" : "2017-09-27",
"rating" : "4",
"review" : "sdfa",
"report" : "some report"
}
]
}