Added Properties to Vegetable

This commit is contained in:
Damien Broqua 2018-10-02 19:18:05 +02:00
parent c9652c1366
commit 6d94b5f60c
9 changed files with 277 additions and 1 deletions

View file

@ -0,0 +1,26 @@
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
}