1

下面是我的代码,但由于某种原因没有保存名字和姓氏?在 Meteor 中创建新用户时如何保存附加信息?我正在使用帐户密码包。

Accounts.createUser({
  email: email,
  password : password,
  profile: {firstName: firstName, lastName: lastName}
}, function (err) {
  if (err) {
    // Inform the user that account creation failed
  } else {
    // Success. Account has been created and the user
    // has logged in successfully. 
  }
});
4

1 回答 1

1

回调应返回即将保存到数据库中的onCreateUserfinall对象。user您遇到的问题来自profile数据需要手动连接到user对象的事实(有关更多详细信息,请参阅流星文档):

Accounts.onCreateUser(function(options, user) {
    // [...]
    if (options.profile)
        user.profile = options.profile;
    return user;
});
于 2013-10-18T14:38:53.067 回答