2014-12-06 60 views
1

我是流星newb,我正在嘗試客戶端的簡單集合查詢。我在根中的common.js文件中聲明瞭Subject集合,因此client/server/文件夾中的文件都可以訪問它。客戶端查詢延遲 - 流星的Mongo集合

問題:當我想通過drop助手在我的home模板中顯示一些Subject數據時,數據會顯示然後消失。 在我的幫助器定義中有一個console.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包,但我在客戶端查詢時一直得到這個延遲。當我在client.js中查詢一個簡單的console.log時,我得到undefined

[編輯2:] meteor刪除udondan:bulk-collection-update完成了這項工作。謝謝。 [編輯]我嘗試刪除所有其他軟件包,重新安裝meteor,嘗試其他瀏覽器(Chrome 39.0.2171.71(64位),Safari 8.0)。我在優勝美地OS X版本10.10.1上。 根/ subject.html:

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

根/ 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... 
+0

我把你的代碼放入[meteorpad](http://meteorpad.com/pad/Mqq94E4EYCk6FJod6/Clientside%20find),它工作正常。我沒有添加你列出的軟件包,所以也許其中一個導致了這個問題。 – user728291 2014-12-06 07:51:01

+0

正如我在編輯中所說:我嘗試刪除所有其他包,重新安裝流星,嘗試另一個瀏覽器(Chrome 39.0.2171.71(64位),Safari 8.0)。我在優勝美地OS X版本10.10.1上。 – 2014-12-06 08:51:02

+0

是的,你是對的......似乎我總是使用批量收集更新軟件包(@Ron是正確的),即使我刪除了所有其他軟件。謝謝。 – 2014-12-06 09:03:53

回答

0

你的代碼對我來說很不錯O操作。

meteor remove udondan:bulk-collection-update 

刪除批量收集更新包。那它有用嗎?

+0

其實這解決了它。我可能忘了嘗試沒有這個確切的包,因爲我總是用它來初始化我的數據庫。謝謝! – 2014-12-06 08:59:06

+0

太棒了! :) 其實,你不必初始化你的分貝。當您在項目根目錄中輸入「meteor」時,Meteor正在爲您做這件事。 使用'udondan:bulk-collection-update'軟件包,您可以使用數組內容更新/替換集合的全部內容。沒有更多,沒有更多。 快速查找後,我認爲它不會爲您啓動某些功能。 :) – Ron 2014-12-06 09:47:25