Schema中的recursion元素:Mongoosebuild模

任何想法在Mongoose模式中build模树文件?

var TreeSchema = new Schema({ "Non-leafNode" : { 'children': [ { type: "NodeElement"}], 'title': String}, "NodeElement: { 'elem':{ type: "LeafNode"}, 'elem2':{ type: "Non-leafNode" }}, // one of them is required. not both. "LeafNode" : { title : String} }); 

怎么能模型呢? 整棵树是一个文件(最好)

https://groups.google.com/forum/#!topic/mongoose-orm/0yUVXNyprx8

按照devise,它可能工作。 没有这方面的testing。 我有Schema#add为此Schema#add ,以产生recursion引用:

 var Tasks = new Schema(); Tasks.add({ title : String , subtasks : [Tasks] }); 

所以你需要逐步构buildrecursion。