我看不到我的用户的任何个人资料信息,知道为什么吗?
服务器 :
Meteor.publish("userData", function () {
return Meteor.users.find({_id: this.userId},
{fields: {'profile': 1}});
});
Meteor.publish("allUsers", function () {
//TODO: For testing only, remove this
return Meteor.users.find({}, {fields: {'profile': 1}});
});
客户 :
Meteor.autosubscribe(function () {
Meteor.subscribe('allUsers',null , function() { console.log(Meteor.users.find().fetch()) });
Meteor.subscribe('userData', null, function() { console.log(Meteor.user())});
});
....
Accounts.createUser({email:email,password:password, profile: {name: name}},function(error){
...
});
我的控制台输出一个对象,第一个对象只有 _id 和电子邮件,第二个对象未定义。配置文件信息(在我的情况下为名称)似乎有效,因为在我的 server.js 中,我有一个可以正常工作的名称验证:
Accounts.onCreateUser(function(options, user) {
if(options.profile.name.length<2)
throw new Meteor.Error(403, "Please provide a name.");
return user;
});
我错过了什么吗?
谢谢!