我的Meteor应用程序(Customers,Projects)中有两个集合,如下所示,我正在尝试根据Project文档中保存的customer_id加入customer.name,但无法找到如何执行此操作。那么有人可以建议我怎么做才能帮忙吗?感谢
Project {_id: "S83NEGHnrefvfASrf", title: "Meteor App 01", customerid: "QDGvBQhS6vYgZtnRr", duedate: "11/15/2014 11:42 PM"}
Customer {_id: "QDGvBQhS6vYgZtnRr", name: "Mary"}
projectslist.js:
Template.projectslist.helpers({
projectsList: function () {
return Projects.find({},{sort: {title: 1}});
}
});
答案 0 :(得分:0)
如果你有
{{#each projectsList}}
{{name}}
{{/each}}
帮助器应该看起来像这样
name: function(){
return Customer.findOne({_id:this.customerid}).name;
},