本文介绍了发布自定义Meteor.user()字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这个问题已经被问过很多遍了,但是我很难发布这些信息.
I know this question has been asked numerous times but I am having a difficult time publishing this information.
在Accounts.onCreateUser中,我要添加一个字段
In Accounts.onCreateUser I am adding a field like so
{
...
user['info'] = { email: options.email, is_admin: false};
}
我发布了此信息;
Meteor.publish('user', function() {
return Meteor.users.find({}, { fields: { info: 1} });
}
和
Meteor.subscribe('user');
在调试后,发布查询将返回正确的信息,但是当我尝试访问Meteor.user()时,该信息永远不会提供给客户端.我是否需要做其他事情以允许Meteor.user()访问信息?
After debugging the Publish query returns the correct information but that is never given to the client when I try to access Meteor.user(). Do I have to do something else to allow info to be access by Meteor.user()?
有什么建议吗?
推荐答案
您将要使用null来发布给单个用户.
You'll want to use null to publish to the single user.
Meteor.publish(null, function() {
return Meteor.users.find({_id: this.userId}, {fields: {info: 1}});
});
这篇关于发布自定义Meteor.user()字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!