gpt4 book ai didi

javascript - Meteor:使用 #each block 中的 id 访问另一个集合

转载 作者:行者123 更新时间:2023-12-03 07:07:59 26 4
gpt4 key购买 nike

所以我有两个集合,应用程序和配置文件,

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);
}
});

关于javascript - Meteor:使用 #each block 中的 id 访问另一个集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36730723/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com