0
我有3层存储在mongoDB中的嵌套对象。 第一层显示它应该的名字,第二层也是如此。 但是当它进入第三层时,它显示文本:“wrappedPointCut” 这是为什么?以及wrapedPointCut是什么意思?为什么我会使用wrappedPointCut而不是数据?
我有一个车把测试这样的代码:
{{#each tierOne}}
<h2>{{ this.tierOneName }}</h2>
{{#each tierTwo}}
<h2>{{ this.tierTwoName }}</h2>
{{#each tierThree}}
<h2>{{ this.tierThreeName }}</h2>
{{/each}}
{{/each}}
{{/each}}
</div>
当通过JS嵌套对象进行迭代,我得到在控制台中正确的输出。另外,如果我添加4个对象到第三层,我会得到4个标题:“wrapedPointCut”。这意味着它知道这里有数据。
这是MongoDB的结构: 这是第3层:
var TierThree = new mongoose.Schema({
tierThreeName : {
type: String
}
});
这是第2层:
var TierTwo = new mongoose.Schema({
tierTwoName : {
type: String
},
tierThree : [TierThree]
});
这是第1层:
var TierOne = mongoose.Schema({
tierOneName : {
type: String,
index:true
},
tierTwo: [TierTwo]
});
以下是将第三层导出到monngoDB的功能:
module.exports.createTierThree = function(newTierThree, tierOne, tierTwoName , callback){
for (var i = 0; i < tierOne.tierTwo.length; i++) {
if(tierOne.tierTwo[i].tierTwoName == tierTwoName){
tierOne.tierTwo[i].tierThree.push(newTierThree);
tierOne.tierTwo[i].save(function (err) {
if (!err) console.log('Success!');
});
}
}
};
如果您显示以json格式导出的数据的一个示例,这将有所帮助 –
我做了一个编辑,我希望这有助于清除它。我非常感谢一些帮助,因为我在这里迷路了。我认为我的问题可能会像我在第一部分中所显示的那样迭代。 – fredriwa
这不是我所期望的:您能否提供一个与您呼叫车把模板的数据样本。 –