I have a nested array, I have to remove the one object , based upon the condition using aggregation个
这是我从MongoDB得到的JSON
{
"_id": "633d275ceb34a28755974032",
"name": "free",
"products": [
{
"title": "Product 1",
"phone": [
{
"title": "Best Phone 1 ",
"video": {
"Location": "https://video.mp4"
},
"freePreview": true
}
]
},
{
"title": "Product 2",
"phone": [
{
"title": "Best Phone 2",
"video": {
"Location": "https://video.mp4"
},
"freePreview": false
}
]
}
]
}
但我需要像这样的数据
{
"_id": "633d275ceb34a28755974032",
"name": "free",
"products": [
{
"title": "Product 1",
"phone": [
{
"title": "Best Phone 1 ",
"video": {
"Location": "https://video.mp4"
},
"freePreview": true
}
]
},
{
"title": "Product 2",
"phone": [
{
"title": "Best Phone 2",
"freePreview": false
}
]
}
]
}
In this data "video object" is removed inside the phone array , because of freePreview is false,个
根据免费预览条件,帮我移除视频对象