我知道这个问题已被问过很多次,但我很难发布此信息。
在 Accounts.onCreateUser 中,我添加一个像这样的字段
{
...
user['info'] = { email: options.email, is_admin: false};
}
我发布此信息;
Meteor.publish('user', function() {
return Meteor.users.find({}, { fields: { info: 1} });
}
and
Meteor.subscribe('user');
调试后,发布查询返回正确的信息,但当我尝试访问 Meteor.user() 时,该信息永远不会提供给客户端。我是否需要做其他事情才能允许 Meteor.user() 访问信息?
有什么建议么?
您需要使用 null 来发布给单个用户。
Meteor.publish(null, function() {
return Meteor.users.find({_id: this.userId}, {fields: {info: 1}});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)