のようなものですので、私は何かが欠けする必要があり、私の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
}
});
です照合は正確でしたが、reblog
コレクションからのデータは、REGとは別にすべてを取り除くためにREGEXで処理する必要がありました私が必要としていたものを配列に変換すると、これはうまくいった最後のコードです。それをここに残して、うまくいけば、それは将来誰かを助けるでしょう。
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);
//turn it into a string so i can extract only the ids
var reblogString = JSON.stringify(rebloged).replace(/"(.*?)"/g, '').replace(/:/g, '').replace(/{/g, '').replace(/}/g, '').replace(/,,/g, ',').replace(/^\[,+/g, '').replace(/\]+$/g, '');
//after have extracted what i needed, i make it into an array
var reblogArr = reblogString.split(',').map(function(item) {
return parseInt(item, 10);
});
//create the relationship between the posts collection and the reblog collection
var reblogger = posts.find({
id: {
$in: reblogArr
}
}).fetch();
//nothing is showing with the log below, so something is going wrong with the line above?
console.log(reblogger);
return reblogger
}
});
私はこれを動作させることはできません。 ** console.log(reblogArr); **は何も表示しない@Michel –
'reblog.find(id).count()とは何ですか? –