From dcc78c725b75fd298fce00ac1284b5ce6c364ac3 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sat, 6 Oct 2018 17:24:11 +0200 Subject: [PATCH] Fixed bug in VegetableProperties --- middleware/Vegetables.js | 6 +++--- models/vegetable_properties.js | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/middleware/Vegetables.js b/middleware/Vegetables.js index 0a4a351..b08d9f7 100644 --- a/middleware/Vegetables.js +++ b/middleware/Vegetables.js @@ -181,9 +181,9 @@ class Vegetables { 'Type', 'Pictures', { - model: models.vegetableProperties, - as: 'Properties', - include: ['Property'] + model: models.vegetableProperties, + as: 'Properties', + include: ['Property'] } ] }) diff --git a/models/vegetable_properties.js b/models/vegetable_properties.js index 015ce9a..99bccb5 100644 --- a/models/vegetable_properties.js +++ b/models/vegetable_properties.js @@ -17,9 +17,10 @@ module.exports = (sequelize, DataTypes) => { as: 'Vegetable', foreignKey: 'id' }) - vegetableProperties.hasOne(models.properties, { + vegetableProperties.belongsTo(models.properties, { as: 'Property', - foreignKey: 'id' + foreignKey: 'propertyId', + targetKey: 'id' }) } return vegetableProperties