fix model associations

This commit is contained in:
Bilal Catic
2019-09-30 13:17:27 +02:00
parent 4713e78d51
commit b703d55c06
3 changed files with 15 additions and 21 deletions

View File

@@ -51,11 +51,5 @@ module.exports = (sequelize, DataTypes) => {
renewedDate: DataTypes.DATE
});
RealEstate.associate = models => {
RealEstate.belongsToMany(models.SearchRequestMatch, {
through: "SearchRequestMatch"
});
};
return RealEstate;
};

View File

@@ -64,11 +64,5 @@ module.exports = (sequelize, DataTypes) => {
}
});
SearchRequest.associate = models => {
SearchRequest.belongsToMany(models.SearchRequestMatch, {
through: "SearchRequestMatch"
});
};
return SearchRequest;
};

View File

@@ -9,15 +9,6 @@ module.exports = (sequelize, DataTypes) => {
autoIncrement: true,
allowNull: false
},
searchRequestId: {
type: DataTypes.UUID,
allowNull: false,
primaryKey: true,
references: {
model: "SearchRequest",
key: "id"
}
},
realEstateId: {
type: DataTypes.BIGINT,
allowNull: false,
@@ -29,6 +20,15 @@ module.exports = (sequelize, DataTypes) => {
onUpdate: "CASCADE",
onDelete: "SET NULL"
},
searchRequestId: {
type: DataTypes.UUID,
allowNull: false,
primaryKey: true,
references: {
model: "SearchRequest",
key: "id"
}
},
notified: {
type: DataTypes.BOOLEAN,
allowNull: false,
@@ -43,5 +43,11 @@ module.exports = (sequelize, DataTypes) => {
}
);
SearchRequestMatch.associate = models => {
SearchRequestMatch.hasMany(models.RealEstate, {
foreignKey: "id"
});
};
return SearchRequestMatch;
};