将架构附加到 Meteor.users

Attaching schema to Meteor.users

本文关键字:Meteor users      更新时间:2023-09-26

我正在尝试自定义我的Meteor.users模式:

Schema.users = new SimpleSchema({
username: {
    type: String,
},
test:{
    type: String,
},
services: {
    type: Object,
    optional: true,
    blackbox: true
}
});

当我打电话给:

Accounts.createUser({username:"lionel",test:"123",password:"123"});

返回的控制台:

Exception while invoking method 'createUser' Error: Test is required
......
Sanitized and reported to the client as: Test is required [400]

我在这里错过了什么?

>Accounts.createUser()希望在profile键中遇到额外的信息。

用:

Accounts.createUser({username:"lionel",password:"123",profile: {test:"123"}});

并在服务器上设置Accounts.onCreateUser()功能:

Accounts.onCreateUser(function(options, user) {
  if (options.profile) user.test = options.profile.test;
  return user;
});

文档