出于某种原因,升级到 0.5.9 后,我遇到了服务器端似乎可以正确发送所有内容的问题,但是客户端却说它什么也没收到。
//服务器:
Meteor.publish("orders", function (ordersQueryParams) {
console.log("orders publish: " + JSON.stringify(ordersQueryParams));
if (this.userId && ordersQueryParams){
console.log("orders collection: " + Orders.find({"customer._id": this.userId}, ordersQueryParams).count());
return Orders.find({"customer._id": this.userId}, ordersQueryParams);
}
});
//客户:
var ordersPreferences = {
table: {
size: 10
},
query: {
sort: {createdDate:-1},
skip : 0,
limit : 10
}
};
Session.set("ordersPreferences", ordersPreferences);
Meteor.autorun(function(){
var ordersPreferences = Session.get("ordersPreferences");
console.log('subscribing to orders');
Meteor.subscribe("orders", ordersPreferences.query);
}
//两个都:
Orders = new Meteor.Collection("orders");
Deps.autorun(function(){
if (Meteor.isServer)
console.log("on server orders count is " + Orders.find().count());
if (Meteor.isClient)
console.log("on client orders count is " + Orders.find().count());
});
服务器日志:
on server orders count is 26
orders publish: {"sort":{"createdDate":-1},"skip":0,"limit":10}
orders collection: 26
客户端日志:
subscribing to orders
on client orders count is 0
为什么服务器说有26 个文档,但客户端坚持0?
这让我发疯:(