我有一个具有分层文档结构的 MongoDB 集合。根层连接到另一个集合,该集合是这些集合的父级。文档架构如下:
{
"_id": objectId, //(1)
"_parentNode": objectId,
"_organisation":objectId // (do the find children job only when this index appears) (2)
"name": string
}
查询后我期望的是
[
{
"_id": objectId, // organisation's $oid (2)
"name": string,
"children": [{objectId},{objectId},...] // list of $oid of (1)
},...
]