且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

流星收集查询“未定义"

更新时间:2023-10-25 14:09:40

您似乎正在使用 autopublish 包.而且(当然),Meteor.startup 不会等待订阅完成.

It seems that you are using autopublish package. And (of course), Meteor.startup doesn't wait subscription completed.

通常,我们使用 reactive context &数据在 Meteor 中执行此操作 -

Usually, we use reactive context & data to do this in Meteor -

datas = new Meteor.Collection("datas")

if (Meteor.is_client){
  Meteor.autosubscribe(function(){
    var data = datas.findOne('101abcde1f2345ac00000001');
    if (data){ console.log( data.name )}
  });
}

任何时候datas集合有变化(?),Meteor.autosubscribe中的函数都会被调用.

Anytime datas collection has changes(?), the function in Meteor.autosubscribe will be called.