我已经搜索了一段时间,但没有找到任何好的答案.我有n-deep棵树,我存储在数据库中,我想填充all parents,所以最后我得到了完整的树
node
-parent
-parent
.
.
-parent
到目前为止,我填充到2级,正如我提到的,我需要达到n级.
Node.find().populate('parent').exec(function (err, items) {
if (!err) {
Node.populate(items, {path: 'parent.parent'}, function (err, data) {
return res.send(data);
});
} else {
res.statusCode = code;
return res.send(err.message);
}
});