0

何らかの理由で 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を主張しますか?

それは私を夢中にさせています:(

4

1 に答える 1

0

私は問題を見つけました:

Meteor.user()私は自分が利用可能になるのを「待っていた」ので、これがありましたautorun

Meteor.autorun(function(handle){
            var ordersPage = new OrdersPage();
            if (Meteor.user()) {
                ordersPage.init();
                ordersPage.autorun();
                handle.stop();
            }
            });
        if (Meteor.user()) {
            return "orders";
        }

が見つかったら、Meteor.user()この関数を実行する必要がないため、handle.stop(). どうやら 0.5.9 からhandle.stop()は、即時だけでなく、autorunその下のすべて (コレクションを含む) も停止します。

Meteor で導入されたバグである可能性があります... または新機能である可能性があります。

于 2013-03-29T21:28:41.133 に答える