Added Properties to Vegetable
This commit is contained in:
parent
c9652c1366
commit
6d94b5f60c
9 changed files with 277 additions and 1 deletions
26
models/vegetable_properties.js
Normal file
26
models/vegetable_properties.js
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue