可以在meteor Accounts.onCreateUser中使用userId吗?

时间:2013-02-13 21:57:24

标签: meteor

我想在创建时初始化用户的默认变量。有没有一种好方法可以做到这一点 - 我尝试在onCreateUser中使用userId但没有成功。

由于

2 个答案:

答案 0 :(得分:2)

仅供参考,从流星0.5.8起,_id现在在OnCreateUser中有效......

答案 1 :(得分:1)

您可以简单地扩展用户集合以添加所需的任何属性:

Accounts.onCreateUser(function(options, user) {
  // We still want the default hook's 'profile' behavior.
  if (options.profile) {
    user.profile = options.profile;
    user.profile.user_status = "new";
  }
  return user;
});

这不会更新users以外的任何集合,因此不能将新用户_id存储为另一个集合中的外键。