【问题标题】:meteor collections simpleschema, allowedvalues for array?流星集合simpleschema,数组的允许值?
【发布时间】:2019-08-30 23:05:49
【问题描述】:

当我创建了一个架构时:

  permissions: {
    type:[String],
    allowedValues: [
      'admin', 'normal',
    ],
  },

allowedValues 检查是否适用于数组内的元素?

【问题讨论】:

    标签: node.js meteor simple-schema


    【解决方案1】:

    根据this feature request,你会使用这个:

    permissions: {
        type:[String]
    },
    permissions.$: {
        type: String,
        allowedValues: [
            'admin', 'normal'
        ],
    }
    

    您需要有一种方法来确保不会将重复值推送到数组中。

    【讨论】:

      猜你喜欢
      • 2014-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-22
      • 2016-01-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多