我正在尝试访问存储在集合中的userId,然后使用它们发布所有meteor.users的详细信息。我的发布功能不是什么都不返回?
Meteor.publish('allUsersWithOffers', function () {
var user = Offers.find({}, {fields: {"UserId": 1}});
return Meteor.users.find({_id: user});
});
答案 0 :(得分:1)
尝试一下:
Meteor.publish('allUsersWithOffers', function () {
var offers = Offers.find({}, { fields: { UserId: 1 } }).fetch();
var ids = _.pluck(offers, 'UserId');
// This is critical - you must limit the fields returned from
// the users collection! Update this as needed.
options = { fields: { username: 1, emails: 1 } };
return Meteor.users.find({ _id: { $in: ids } }, options);
});
find
返回一个游标 - 您需要调用fetch
来实际获取文档。