简体   繁体   English

在流星客户端上查找不起作用

[英]Find on meteor client don't work

I'm trying to do a pretty basic example using meteor js. 我正在尝试使用流星js做一个非常基本的示例。 In my lib folder (shared by client and server) i have the following code 在我的lib文件夹(由客户端和服务器共享)中,我有以下代码

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

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

In folder server/libs i have this code 在文件夹服务器/库中,我有此代码

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

(Which log one element) (记录一个元素)

In my client/libs folder i have this code 在我的client / libs文件夹中,我有此代码

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

(Which logs no element) (不记录任何元素)

It used to work, but now it stops. 它曾经可以工作,但是现在停止了。

Just to be clear i'm running on windows, and i removed and added again the autopublish package. 为了清楚起见,我在Windows上运行,然后我删除并再次添加了autopublish软件包。

I think find needs to take an argument. 我认为发现需要争论。 See http://docs.meteor.com/#find 参见http://docs.meteor.com/#find

If you are wanting the first element there are other ways of getting it. 如果您想要第一个元素,那么还有其他方法可以获取它。 http://docs.meteor.com/ http://docs.meteor.com/

Try find({}) with empty curly braces 尝试使用大括号为空的find({})

The data probably hasn't reached the client yet when you do that find. 当您进行查找时,数据可能尚未到达客户端。 Try wrapping those 3 lines of client code in a Deps.autorun 尝试将这三行客户端代码包装在Deps.autorun中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM