【发布时间】:2017-04-09 09:41:28
【问题描述】:
我正在使用带有 mongoose 的 express 框架,并且我有以下 Schema:
var DocumentSchema = new Schema({
name: String,
description: String,
parent: {
type: Schema.Types.ObjectId,
ref: "Document"
},
children: [{
type: Schema.Types.ObjectId,
ref: 'Document'
}]
});
我正在尝试获取子级的动态层次结构树,但找不到任何合适的解决方案。
是否可以使用此架构来做到这一点?如果不是,我应该使用什么模式结构?
【问题讨论】:
标签: node.js mongodb express mongoose mongoose-schema