【发布时间】:2014-12-06 17:06:16
【问题描述】:
我是 Meteor 新手,我正在客户端尝试一个简单的集合查询。我在根目录的 common.js 文件中声明了 Subject 集合,因此 client/ 和 server/ 文件夹中的文件都可以访问它。
问题:当我想通过drop 帮助器在我的home 模板中显示一些Subject 数据时,数据会显示然后消失。
在我的助手定义中使用 console.log,我看到数据按以下顺序显示,日志记录之间有约 20 秒的延迟。
[][Object][][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 包,但是当我在客户端查询时,我一直遇到这种延迟。当我在 client.js 中执行简单的console.log 查询时,我得到undefined。
[Edit2:] meteor remove udondan:bulk-collection-update 完成了这项工作。谢谢你。 [编辑:] 我尝试删除所有其他软件包,重新安装流星,尝试另一个浏览器(Chrome 39.0.2171.71(64 位),Safari 8.0)。我使用的是 Yosemite OS X 版本 10.10.1。 根/subject.html:
<template name="home">
{{#each drop}}
Smth {{this.term}}
{{/each}}
</template>
root/common.js:
Subject = new Mongo.Collection("subject");
客户端/client.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...
【问题讨论】:
-
我将您的代码放入a meteorpad,它工作正常。我还没有添加您列出的软件包,所以其中一个可能会导致问题。
-
正如我在编辑中所说:我已经尝试删除所有其他软件包,重新安装流星,尝试其他浏览器(Chrome 39.0.2171.71(64 位),Safari 8.0)。我使用的是 Yosemite OS X 版本 10.10.1。
-
是的,你是对的......似乎我总是使用批量收集更新包(@Ron 是对的),即使我删除了所有其他包。谢谢。
标签: javascript mongodb meteor