module.exports = (sequelize, DataTypes) => { const vegetables = sequelize.define('vegetables', { name: DataTypes.STRING, mainPicture: DataTypes.STRING, description: DataTypes.TEXT, lat: DataTypes.INTEGER, lng: DataTypes.INTEGER, vegetableTypes_id: { type: DataTypes.INTEGER, references: 'vegetableTypes', referencesKey: 'id' } }, {}) vegetables.associate = function (models) { vegetables.hasOne(models.vegetableTypes, { as: 'VegetableTypes', foreignKey: 'vegetableTypes_id' }) vegetables.hasMany(models.vegetablePictures, { as: 'Pictures', onDelete: 'cascade' }) } return vegetables }