我想获取所有带有子文档嵌套数组的文档。在mongodb中怎么办?
[
{
"_id": "5f2baa334d1a021d2126c5c7",
"mode": "TEST",
"title": "RAPID_TEST",
"sequence": 1,
"workouts": {
"_id": "5f2baa334d1a021d2126c5c8",
"detail": "5f2ba9f99699c11cfa02e8be",
"duration": 30,
"sequence": 1
},
"totalDuration": 60,
"__v": 0
},
{
"_id": "5f2baa334d1a021d2126c5c7",
"mode": "TEST",
"title": "RAPID_TEST",
"sequence": 1,
"workouts": {
"_id": "5f2baa334d1a021d2126c5c9",
"detail": "5f2baa01b7e0e01d01cbcccb",
"duration": 30,
"sequence": 2
},
"totalDuration": 60,
"__v": 0
}
]
使用 entity.find()或** entity.aggreate([{$ unwind:{路径:“ $ subdocAttribute”}}}])。给我以上结果。