这应该是流星中简单的多对多关系,但我必须遗漏一些东西,因为我无法让它工作。
我有一个名为reblogdescovered
的集合,其中有一个名为see image的整数数组
我有第二个集合,称为帖子,它是帖子的集合,这些帖子有一个 ID。看看第二张图片
我想在帖子和转发集合之间创建多对多关系。即,我想匹配整数
descovered: 9
来自 reblog 集合,其中:
id: 9
从帖子集合中,以便我只能显示与转发集合匹配的帖子。这当然可以让我显示帖子的标题和其他属性。
这是我的js
Template.reblogging.helpers({
descovered() {
var id = FlowRouter.getParam('_id');
//fetch the reblog collection contents
var rebloged = reblog.find().fetch();
//log below is showing that the fetch is successful because i can see the objects fetched in console
console.log(rebloged);
//create the relationship between the posts collection and the reblog collection
var reblogger = posts.find({
id: {
$in: rebloged
}
}).fetch();
//nothing is showing with the log below, so something is going wrong with the line above?
console.log(reblogger);
return reblogger
}
});
我一定遗漏了一些东西,因为这似乎是一件很简单的事情,但它没有用
我的HTML是这样的
<template name="reblogging">
{{#each descovered }}
<ul class="">
<li>
<h5 class="">{{title.rendered}}</h5>
</li>
</ul>
{{/each}}
</template>