Javascript Angular-Meteor:Publish返回完整的数据集,而不是参数化的数据集

Javascript Angular-Meteor:Publish返回完整的数据集,而不是参数化的数据集,javascript,angularjs,mongodb,meteor,publish-subscribe,Javascript,Angularjs,Mongodb,Meteor,Publish Subscribe,因此,我在Angular Meteor项目中有一个MongoDB集合,我想使用find或findOne方法返回集合的子集(特定的一项) 下面我们来看看: Meteor.publish('eventById', function(eventId){ console.log("The eventId you received is as follows:"); console.log(eventId); return Events.find({ _id: eventId }); });

因此,我在Angular Meteor项目中有一个MongoDB集合,我想使用find或
findOne
方法返回集合的子集(特定的一项)

下面我们来看看:

Meteor.publish('eventById', function(eventId){
  console.log("The eventId you received is as follows:");
  console.log(eventId);
  return Events.find({ _id: eventId });
});
我得到的eventId是正确的(看起来像yfzeudfelawiwted)。但是,当我将实际返回值记录在控制台日志中时,我得到了包含所有数据块的完整数组。我只需要一个基于Id的

我的控制器代码如下所示:

var self = this;
  self.currentEventId = $stateParams.id;
  self.currentEvent = $scope.$meteorCollection(Events, false).subscribe('eventById', self.currentEventId);

  console.log(self.currentEventId);
  console.log(self.currentEvent);
记录
self.currentEvent
为我提供了与常规
Events.find()调用相同的数组

事件的架构如下所示:

{
"title": "Meteor Power Lunch",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sem nisl, mattis nec odio at, dignissim pharetra elit. Aliquam non ante enim. Praesent quis convallis.",
"date": "04/05/2016",
"imageUrl": "/images/bizz-party.jpg",
"bannerUrl": ""
}

我期望得到的是这些对象中的一个,而Events是这些事件的Mongo集合。我以这种方式通过url()传入这些项目的生成ID。

使用
findOne()
方法有什么问题?'findOne()方法方法也不会返回正确的数据。如果我想按id查找,您能否给我一个示例,说明该方法应该是什么样子?可能会有所帮助,但需要一些突出的细节,如
事件
收集模式的外观、一些示例数据和您预期的输出。然后你能使用链接在你的问题中包含这些细节吗?我编辑了我的问题。希望您有您需要的:)返回以下错误:
子eventById XceGk8QHJ7cdwtJ8Y异常错误:发布函数只能返回游标或游标数组