2016-07-20 146 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 } 
    },