问题
Trying to update an inner array document. There are three levels of the nested array. I am able to remove till the second level but not able to update the third level
{
"id":"Test",
"name":"Test",
"sections":[
{
"sectionname":"Example1",
"sectionroles":["test1", "test2", "test3"],
"subcategory":[
{
"Value":"demo",
"ValueId":"123333333333",
"sectionroles":["test1", "test2", "test3"],
},
{
"Value":"Example2",
"Value":"6577544333333",
"sectionroles":["test1", "test2", "test3"],
}
]
}
I am able to remove the sections through the section name but not able to remove the subcategory.
Query query = new Query(Criteria.where("name").is("Test"));
query.fields().elemMatch("sections",
Criteria.where("sectionname").is("Example1"));
Update update = new Update();
update.pull("sections", new BasicDBObject("sectionname",
"Example1"));
mongotemplate.updateMulti(query, update, "menu");
What do I add in the existing Criteria to remove or add any value in a subcategory ???
来源:https://stackoverflow.com/questions/57722566/spring-mongo-nested-inner-query