這應該是一個簡單的流星多對多關係,但我必須錯過一些東西,因爲我無法讓它工作。如何匹配一個集合中的整數與另一個集合中的整數相同,從而創建多對多關係。
我有一個名爲收集一個reblog並在它被稱爲descovered
看到圖像
我有一個名爲帖子第二收集這是帖子的集合整數數組,並這些帖子有一個ID。看看第二圖像
我想創建一個多到職位和一個reblog集合之間的多對多關係。即,我想整
descovered: 9
從一個reblog集合匹配,具有:
id: 9
從帖子集合,這樣我可以只顯示從匹配的職位reblog集合。這當然會讓我顯示帖子的標題和其他屬性。
這是我的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>
我不能得到這個工作。 ** console.log(reblogArr); **不顯示任何內容,@Michel –
什麼是'reblog.find(id).count()'? –