26 lines
679 B
JavaScript
26 lines
679 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.hasOne(models.properties, {
|
|
as: 'Property',
|
|
foreignKey: 'id'
|
|
})
|
|
}
|
|
return vegetableProperties
|
|
}
|