Test Data:-
professor:{
name:"temp1",
department:[
{name:"pro1",
review:[
{paper:"paper1",status:"review",paperid:"1"}
]}]}
I want to update the status "review" to "finish".
For to search I use :
{
department: {
$elemMatch: {
review: {
$elemMatch: {
paperid: id
}
}
}
}}
2
Answers
If you want to update all your documents where the status is
review
use:See how it works on the playground example
If you want to update only where the
department.name
ispro1
use:See how it works on the playground example – department
by specify paperid