2018-10-02 19:18:05 +02:00
|
|
|
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'
|
|
|
|
})
|
2018-10-06 17:24:11 +02:00
|
|
|
vegetableProperties.belongsTo(models.properties, {
|
2018-10-02 19:18:05 +02:00
|
|
|
as: 'Property',
|
2018-10-06 17:24:11 +02:00
|
|
|
foreignKey: 'propertyId',
|
|
|
|
targetKey: 'id'
|
2018-10-02 19:18:05 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return vegetableProperties
|
|
|
|
}
|