我只会查询到学习1下的学院2,请问再查专业2改怎么写呢 db.collection('school') .aggregate() .match({ schoolName: '学校1' }) .project({ academyList: $.filter({ input: '$academyList', as: 'item', cond: $.eq(['$$item.academyName', '学院2']) }) }) .end()
云开发,集合有两条数据,怎么取学校1,学院2,专业2的majorBookList数组?data: [ { _id: '1', schoolName: '学校1', academyList: [ { academyId: '1', academyName: '学院1', majorList: [ { majorId: '1', majorName: '专业1', majorBookList: [], }, ] }, { academyId: '2', academyName: '学院2', majorList: [ { majorId: '1', majorName: '专业1', majorBookList: [], }, { majorId: '2', majorName: '专业2', majorBookList: [], }, ] }, ], }, { _id: '2', schoolName: '学校2, academyList: [], }, ]
2022-03-23