2
I’m making a database and it has some properties and it has users.
A user can have several properties, so in the properties table I inserted the column user_id
, to reference the user.
But when I create the properties table by sequelize-cli. FK looks like this:
user_id: {
type:Sequelize.INTEGER,
references: { model:'users', key:'id'},
onUpdate:'NO ACTION',
onDelete:'NO ACTION',
allowNull:false
}
The onUpdate
, would be when deleting a property, doing nothing on users and the same thing to onDelete
. But here comes my question, I wanted that when I deleted the user, also delete all properties that it has.
How do I do that?
NOTE: Admit properties as real estate