【发布时间】:2013-04-22 17:58:53
【问题描述】:
我正在尝试做这个 mongo 示例正在做的事情,但在 mongoose 中。对我来说,猫鼬似乎更复杂。可能我想在圆孔中安装一个方形钉?
这个例子来自http://www.codeproject.com/Articles/521713/Storing-Tree-like-Hierarchy-Structures-With-MongoD(带有父引用的树结构)
我正在尝试构建路径。
var path=[];
var item = db.categoriesPCO.findOne({_id:"Nokia"});
while (item.parent !== null) {
item=db.categoriesPCO.findOne({_id:item.parent});
path.push(item._id);
}
path.reverse().join(' / ');
谢谢!
【问题讨论】:
标签: javascript node.js mongodb mongoose