0
訂閱不返回結果我有以下代碼:流星發佈和使用選擇
import { Meteor } from 'meteor/meteor';
import { Items } from './collection';
if (Meteor.isServer) {
Meteor.publish('items', function(options, owner) {
let selector = {
$and: [{ ownerId: owner}]
}
return Items.find(selector, options);
});
}
而在客戶端,我有:
this.subscribe('items',() => [{
limit: this.getReactively('querylimit'),
sort: {dateTime: -1}
},
this.getReactively('ownerId')
]);
以上不返回任何結果。但是,當我將return語句更改爲以下內容時,它可以工作!
return Items.find({ ownerId: '7QcWm55wGw69hpuy2' }, options); //works !!!
我不是很熟悉Mongo/Meteor查詢選擇器。將查詢作爲變量傳遞給Items.find()似乎在搞亂某些東西。有人可以幫我解決這個問題!
謝謝
感謝。我現在在手機上,所以我現在無法檢查。但是,我想知道爲什麼我能夠在服務器端使用console.log來打印參數。 console.log(selector)打印我在第二個return語句中粘貼的ownerId字符串。 – Neo
我誤解了原來的問題並做了一些修改。 –
再次感謝,但是這似乎並沒有解決問題 – Neo