module.exports = (sequelize, DataTypes) => {
  const vegetableProperties = sequelize.define('vegetableProperties', {
    vegetableId: {
      type: DataTypes.INTEGER,
      references: 'vegetables',
      referencesKey: 'id'
    },
    propertyId: {
      type: DataTypes.INTEGER,
      references: 'properties',
      referencesKey: 'id'
    },
    value: DataTypes.TEXT
  }, {})
  vegetableProperties.associate = function (models) {
    vegetableProperties.hasOne(models.vegetables, {
      as: 'Vegetable',
      foreignKey: 'id'
    })
    vegetableProperties.belongsTo(models.properties, {
      as: 'Property',
      foreignKey: 'propertyId',
      targetKey: 'id'
    })
  }
  return vegetableProperties
}