【发布时间】:2019-03-09 17:48:15
【问题描述】:
我不知道如何选择'$graphLookup or $lookup' 其他类似
期待mongodb官方更完整的文档
示例:
{parentId: 0, cid: 1, other: 'a'},
{parentId: 0, cid: 2, other: 'b'},
{parentId: 0, cid: 3, other: 'c'},
{parentId: 1, cid: 11, other: 'aa'},
{parentId: 2, cid: 12, other: 'ab'},
{parentId: 3, cid: 13, other: 'ac'},
结果:
{
parentId: 0, cid: 1, other: 'a',
children: [
{parentId: 1, cid: 11, other: 'aa'},
]
},{
parentId: 0, cid: 2, other: 'b',
children: [
{parentId: 2, cid: 12, other: 'ab'},
]
},{
parentId: 0, cid: 3, other: 'c',
children: [
{parentId: 3, cid: 13, other: 'ac'},
]
}
},
怎么办?
【问题讨论】: