这是我的收藏'文章':
{
"_id" : "ataRpHNmzznphBLCY",
"title" : "Article" }
{
"_id" : "Mp7GooaRdYzekRq8R",
"title" : "Category 1",
"parent" : "ataRpHNmzznphBLCY"
}
{
"_id" : "ieGRjyYQZ8xAQMX9i",
"title" : "Category 2",
"parent" : "ataRpHNmzznphBLCY"
}
模板
<template name="editor">
{{#each section}}
<h1>{{title}}</h1>
<ul>
<li><input class="newElement" data-section="{{_id}}" type="text"></li>
</ul>
{{/each}}
</template>
辅助
Template.editor.helpers({
section: function(){
var articleId = Session.get('articleId'); // = 'ataRpHNmzznphBLCY'
return Articles.find({ parent: articleId });
}
});
但我没有得到输出。似乎section
是空的。但我不明白为什么我在做db.articles.find({ parent: 'ataRpHNmzznphBLCY' }).pretty()
我得到两个结果。