模型描述中“enum”和“in”之间的区别

问题描述 投票:1回答:1

这两个模型定义之间有什么区别吗?他们似乎都工作,我在文档中找不到任何东西。

module.exports = {
    schema: true,

    attributes: {
         state: {
           type: 'string',
           enum: [
               'requested',
               'rejected',
               'accepted'
            ]
          }, 
    }
}

还有这个:

module.exports = {
    schema: true,

    attributes: {
         state: {
           type: 'string',
           in: [
               'requested',
               'rejected',
               'accepted'
            ]
          }, 
    }
}

我看到particlebanana推荐有人在这里使用“in”sails-mysql schema datatypes,但enum似乎工作相同?

mysql sails.js waterline
1个回答
1
投票

它应该是相同的,基于这个参考Waterline Docs

而这source code

// use the Anchor `in` method for enums
  if(prop === 'enum') {
    self.validations[attr]['in'] = attrs[attr][prop];
    return;
  }
© www.soinside.com 2019 - 2024. All rights reserved.