简体   繁体   English

将架构附加到Meteor.users

[英]Attaching schema to Meteor.users

I'm trying to customise my Meteor.users schema: 我正在尝试自定义我的Meteor.users模式:

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

And when I call: 当我打电话时:

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

Console returned: 控制台返回:

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

What am i missing here? 我在这里想念什么?

Accounts.createUser() expects extra info to come across in a profile key. Accounts.createUser()希望在profile密钥中包含更多信息。

Use: 采用:

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

And set up an Accounts.onCreateUser() function on the server: 并在服务器上设置一个Accounts.onCreateUser()函数:

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

docs docs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM