api/models/vegetable_properties.js
2018-10-06 17:24:11 +02:00

27 lines
713 B
JavaScript

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
}