将值从用户配置文件分配给collection2架构

时间:2016-07-20 16:25:31

标签: meteor

如何将meteor配置文件的值分配给collection2架构?我需要分配电子邮件地址和姓名。

我认为它可能是这样的但不是:

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

有什么想法吗?

1 个答案:

答案 0 :(得分: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 }
    },