流星:在#each 块中访问另一个具有 id 的集合

Meteor: Accessing another collection with an id in an #each block

所以我有两个系列,应用器和配置文件,

appliers = {_id,idAppliersProfile}

&

profile = {_id,profilename}

所以我的问题是,如果我为应用程序执行 #each,我如何访问配置文件集合以获取配置文件而不仅仅是 ID? 谢谢

假设两组文档都发布给客户端,一个解决方案如下所示:

html

<template name="myTemplate">
  {{#each appliers}}
    {{#with getProfile idAppliersProfile}}
      <div>{{profilename}}</div>
    {{/with}}
  {{/each}}
</template>

js

Template.myTemplate.helpers({
  appliers: function () {
    return appliers.find();
  },

  getProfile: function (id) {
    return profile.findOne(id);
  }
});