Javascript 服务器上的Meteor.publish不';无法在客户端上显示新文档
问题是服务器上的下一个代码:Javascript 服务器上的Meteor.publish不';无法在客户端上显示新文档,javascript,meteor,publish-subscribe,mongo-collection,Javascript,Meteor,Publish Subscribe,Mongo Collection,问题是服务器上的下一个代码: Meteor.publish(null , function() { let events = []; Groups.find({participants: this.userId}).forEach(function(item) { events.push(item.latestEvent); }); return Events.find({_id: {$in: events}}); }); 无法在客户端上查看新文
Meteor.publish(null , function() {
let events = [];
Groups.find({participants: this.userId}).forEach(function(item) {
events.push(item.latestEvent);
});
return Events.find({_id: {$in: events}});
});
无法在客户端上查看新文档>Events.find().fetch()
无需重新加载页面
两个集合都位于lib
文件夹中:
Groups = new Mongo.Collection('groups');
Events = new Mongo.Collection('events');
我很确定问题出在被动的数据源中,但仍然无法解决
谢谢你的帮助 是的,你是对的:只有事件收集是被动的。使用软件包有一种简单的解决方法:
但这种解决方案有一个缺点:也会发布组文档。所以,您可能应该从中排除一些字段。是的,您是对的:只有事件集合是被动的。使用软件包有一种简单的解决方法: 但这种解决方案有一个缺点:也会发布组文档。所以,您可能应该从中排除一些字段
Meteor.publishComposite(null, {
find(){
return Groups.find({participants: this.userId});
},
children: [{
find(group){
return Events.find({_id: {$in: group.latestEvent}});
}
}]
});