Meteor发布不适用于findOne

时间:2015-12-05 16:25:57

标签: meteor

我试图在发布方法中使用findOne,但如果我不使用集合,我似乎会收到错误。那是发布方法的问题吗?

错误:

I20151205-10:59:28.478(-5)? Exception from sub userConnections id YdJbkeazXZqZayFLd Error: Publish function can only return a Cursor or an array of Cursors
I20151205-10:59:28.479(-5)?     at [object Object]._.extend._publishHandlerResult (livedata_server.js:1107:18)
I20151205-10:59:28.479(-5)?     at [object Object]._.extend._runHandler (livedata_server.js:1038:10)
I20151205-10:59:28.479(-5)?     at [object Object]._.extend._startSubscription (livedata_server.js:842:9)
I20151205-10:59:28.480(-5)?     at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
I20151205-10:59:28.480(-5)?     at _.extend.processMessage.processNext (livedata_server.js:548:43)

发布方法

Meteor.publish('userConnections', function(){
    if(!this.userId){
       return;
    }
    return Connections.findOne({userId: this.userId});
})

下标方法

$scope.$meteorSubscribe('userConnections').then(function(){
     $scope.userContacts = $scope.$meteorObject(Connections);
    }, false);

更新

我在之前的stackflow answer中没有看到任何关于我们可以使用发布方法的解释。你能解释一下吗?

0 个答案:

没有答案
相关问题