从meteor/节点js的客户端收集

我正在尝试使用meteor从客户端获得一个集合。

来自客户:

Template.mapBody.onCreated(function() { var date = this.subscribe("friendUsers"); for (x in date) { console.log(x); } }); 

从服务器:

 if (Meteor.isServer){ Meteor.publish("friendUsers", getFriendUsers); function getFriendUsers() { return Ski_Stations.find(); } } 

我在控制台中什么也没得到。 有人对这个问题有什么想法吗?

从meteor文档 – Meteor.subscribe返回一个订阅句柄,这非常适合停止或看到订阅是否准备就绪。 但我不确定在这种情况下这是你想要的。 我想你会想要迭代像这样的集合..

 var friendCursor = friendUsers.find(); var friend; while ( friendCursor.hasNext() ) { friend = friendCursor.next(); console.log( friend.somefieldhere ); }