2016-07-20 147 views
0

如何将流星配置文件的值分配给collection2架构?我需要分配电子邮件地址和名称。将用户配置文件的值分配给collection2架构

我想这可能是这样,但它不是:

email: { 
     type: String, 
     regEx: SimpleSchema.RegEx.Email, 
     defaultValue: function() { return this.user().emails[0].address } 
    }, 

任何想法?

回答

0

这个整理它的电子邮件地址:

 email: { 
      type: String, 
      regEx: SimpleSchema.RegEx.Email, 
      defaultValue: function(){ return Meteor.user().emails[0].address } 
     }, 

对于配置文件名称:

firstName: { 
     type: String, 
     regEx: /^[a-zA-Z]{2,25}$/, 
     defaultValue: function(){ return Meteor.user().profile.name } 
    },