Meteor发布的唯一用户总是不返回或未定义



我想知道为什么Meteor.users.find(this.userId);总是不返回任何内容。当我在控制台this.userId上回显时,它会打印出来。

代码:

Meteor.publish('login.user', function () {
if (this.userId) {
console.log( "current logged in user ---" +this.userId );
var users = Meteor.users.find( this.userId );
if ( users && users._id ) {
console.log( "meteor.users.find() call  --  " +users && users._id );
return users && users._id;
}
}
});

控制台日志

I20180803-11:59:20.085(1)? current logged in user ---7EQGhuBszukhsYQa3

find不返回文档(它返回一个游标(。改为使用findOne

var users = Meteor.users.findOne( this.userId );

最新更新