【发布时间】:2015-03-03 00:46:17
【问题描述】:
我正在尝试将所有用户名发布给客户端,即使没有登录。为此,在我拥有的服务器上:
Meteor.publish("users", function() {
return Meteor.users.find({}, {fields : { username : 1 } });
});
在客户端:
Meteor.subscribe("users");
但是,当我尝试访问 Meteor.users 集合时,我什么也没找到。
(这与这里的问题基本相同:Listing of all users in the users collection not working first time with meteor js,只是没有先检查管理员的角色。似乎仍然不起作用..)
我可能错过了一些愚蠢的东西..
【问题讨论】:
-
您尝试在客户端的何处访问此光标?
-
您确定在访问数据时订阅已准备就绪?
-
@stubailo 这有关系吗?反应式模型不应该在准备好后更新我的数据吗?
-
那么您在显示所有用户的模板中可能做错了。
-
@PeppeL-G 与模板无关。 count() 返回 0。
标签: meteor