api/models/vegetable_properties.js

27 lines
679 B
JavaScript
Raw Normal View History

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