Search code examples
mysqlsails.jswaterline

difference between "enum" and "in" in model description


Is there any difference between these two model definitions? They both seem to work and I can't find anything in the docs.

module.exports = {
    schema: true,

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

And this one:

module.exports = {
    schema: true,

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

I saw particlebanana recommend someone use "in" here sails-mysql schema datatypes, but enum seems to work the same?


Solution

  • It should be same, based on this reference Waterline Docs

    And this source code

    // use the Anchor `in` method for enums
      if(prop === 'enum') {
        self.validations[attr]['in'] = attrs[attr][prop];
        return;
      }