Javascript 在meteor客户端don'上查找;行不通
我试图用meteor js做一个非常基本的例子。 在我的lib文件夹(由客户端和服务器共享)中,我有以下代码Javascript 在meteor客户端don'上查找;行不通,javascript,meteor,Javascript,Meteor,我试图用meteor js做一个非常基本的例子。 在我的lib文件夹(由客户端和服务器共享)中,我有以下代码 if (typeof hair === 'undefined') { hair = {}; } if (!hair.dao) { hair.dao = {}; } hair.dao.store = (function() { return new Meteor.Collection('store'); })(); 在文件夹服务器/libs中,我有以下代码 Me
if (typeof hair === 'undefined') {
hair = {};
}
if (!hair.dao) {
hair.dao = {};
}
hair.dao.store = (function() {
return new Meteor.Collection('store');
})();
在文件夹服务器/libs中,我有以下代码
Meteor.startup(function() {
console.log(hair.dao.store.find().fetch());
});
var cursorStores;
cursorStores = hair.dao.store.find();
console.log(cursorStores.fetch());
(哪个日志记录一个元素)
在我的client/libs文件夹中,我有以下代码
Meteor.startup(function() {
console.log(hair.dao.store.find().fetch());
});
var cursorStores;
cursorStores = hair.dao.store.find();
console.log(cursorStores.fetch());
(不记录任何元素)
它过去工作,但现在停止了
为了清楚起见,我是在windows上运行的,我删除并再次添加了autopublish包。我认为find需要一个参数。看 如果你想要第一个元素,还有其他的方法
尝试用空大括号查找({})进行查找时,数据可能尚未到达客户端。尝试将这3行客户端代码包装在Deps.autorunHmm中,就像每次调用hair.dao.store时一样。如果要返回新集合,请尝试一次创建集合并返回光标。