繁体   English   中英

流星使用户的模式集合2登录

[英]meteor make user's schema collection2 to login

我想将此模式用作用户并登录或扩展表单用户。我阅读了文档,但不了解如何从用户扩展。 我该怎么做?

Dipendenti = new Mongo.Collection('dipendenti'); DipendentiSchema = new SimpleSchema({ nome: { type: String }, cognome:{ type: String }, codiceFiscale:{ type: String }, telefono:{ type: String }, indirizzo:{ type: String } });

我相信您正在尝试将上面列出的架构扩展/合并到用户集合。 如果是这样,您只需要将架构附加到集合即可。

Meteor.users.attachSchema(DipendentiSchema);

更新:

要使用这个新的合并模式,您应该能够执行以下操作:

Accounts.createUser({
  username: 'test',
  email: 'test@example.com',
  password: 'password',
  nome: 'Richard',
  cognome: 'Ortiz',
  codiceFiscale: 'EUR',
  telefono: '+39 06 49911',
  indirizzo: 'Piazzale Aldo Moro, 5, 00185 Roma, Italy'
});

如果要在架构中将电子邮件地址设为可选,则可以在其中添加以下内容。

emails: {
    optional: true,
    type: [Object]
},
"emails.$.address": {
    optional: true,
    type: String
},
"emails.$.verified": {
    optional: true,
    type: Boolean
}

更新2:

确保要在试图对用户集合进行更改的任何地方定义并附加模式。 为了安全起见,通常只在服务器上进行数据库更改是最佳实践。 您可以使用Meteor.methods({});在服务器上编写一个方法Meteor.methods({}); 然后使用Meteor.call({});在客户端上调用它 并传递您的用户数据。 您可以阅读有关流星文档中这种方法的更多信息。

暂无
暂无

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

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