客户端查询延迟 - Meteor's Mongo Collections

Delay on client side query - Meteor's Mongo Collections

本文关键字:Mongo Collections 查询 延迟 Meteor 客户端      更新时间:2023-09-26

我是Meteor新手,我正在客户端尝试一个简单的集合查询。我在根目录中的通用文件中声明了Subject集合.js因此client/server/文件夹中的文件都可以访问它。

问题:当我想通过drop帮助程序在home模板中显示一些Subject数据时,数据会显示,然后消失。使用控制台.log在我的帮助程序定义中,我看到数据按以下顺序显示,日志记录之间有 ~20 秒的延迟。

  1. []
  2. [Object]
  3. []
  4. [Object]

如果我查询服务器,结果是快速和正确的。我的对象如下所示:

{"_id":"b97SpxtduH2spqLXw","id":"15920","upd":"2013-12-29 04:42:16","uuid":"be81554a-7759-11e4-adb6-57ce06b062da","term_id":"9000","lang":"en","part_speech":"","gender":"","term":"Terminologia Morphologica","source":"","description":"","wiki":"","email":""}]

我已经将我的代码剥离为我向您展示的内容。我有autopublish包,但是当我在客户端查询时,我总是遇到这种延迟。当我在客户端内对查询进行简单console.log时.js我得到undefined.

[编辑2:] 流星删除乌东丹:批量收集更新完成了这项工作。谢谢。[编辑:]我尝试删除所有其他软件包,重新安装meteor,尝试其他浏览器(Chrome 39.0.2171.71(64位(,Safari 8.0(。我使用的是优胜美地OS X版本10.10.1。root/subject.html:

<template name="home">
  {{#each drop}}
    Smth {{this.term}}
  {{/each}}
</template>

根/通用.js:

Subject = new Mongo.Collection("subject");
客户端

/客户端.js:

Template.home.helpers({
  drop: function () {
    var c = Subject.find({uuid: "be81554a-7759-11e4-adb6-57ce06b062da", lang: "en"}).fetch();
    console.log(c);
    return c;
  }
});

我的流星包:

Users-MBP:subject user$ meteor list
accounts-github                 1.0.2  Login service for Github accounts
accounts-google                 1.0.2  Login service for Google accounts
accounts-twitter                1.0.2  Login service for Twitter accounts
accounts-ui                     1.1.3  Simple templates to add login widgets ...
autopublish                     1.0.1  Publish the entire database to all cli...
insecure                        1.0.1  Allow all database writes by default
iron:router                     1.0.3  Routing specifically designed for Meteor
meteor-platform                 1.2.0  Include a standard set of Meteor packa...
nooitaf:semantic-ui             1.1.2  Semantic UI packaged for Meteor
udondan:bulk-collection-update  0.2.0  Bulk insert/update/delete documents in...

你的代码对我来说也很棒。

meteor remove udondan:bulk-collection-update

删除批量收集更新包。那行得通吗?