2013-10-10 272 views
0

我想用流星js做一個很基本的例子。 以我lib文件夾我有以下代碼流星客戶端找不到工作

if (typeof hair === 'undefined') { 
    hair = {}; 
} 
if (!hair.dao) { 
    hair.dao = {}; 
} 

hair.dao.store = (function() { 
    return new Meteor.Collection('store'); 
})(); 

(由客戶端和服務器共享的)在文件夾服務器/庫我有此代碼

Meteor.startup(function() { 
    console.log(hair.dao.store.find().fetch()); 
}); 

(哪些日誌一種元素)

在我的客戶端/庫文件夾中我有這個代碼

var cursorStores; 
cursorStores = hair.dao.store.find(); 
console.log(cursorStores.fetch()); 

(其中不記錄任何元素)

它曾經工作,但現在停止。

只是要清楚我在Windows上運行,我刪除並再次添加autopublish包。

+0

嗯,看起來像每次調用hair.dao.store你都返回新的集合,嘗試使收集一次,並返回光標。 – Denis

+0

我更新了我的答案 – penner

回答

1

數據可能當你這樣做覺得還沒有達到客戶呢。嘗試在Deps.autorun中包裝這3行客戶端代碼