i have two model create with Sequelize cli first model user_number secound model emailSign my models is 1 - user_number model
'use strict';
module.exports = function(sequelize, DataTypes) {
var user_number = sequelize.define('user_number', {
user_id: DataTypes.INTEGER,
callRoute_id: DataTypes.INTEGER,
password: DataTypes.STRING,
}, {
underscored: true,
classMethods: {
associate: function(models) {
// associations can be defined here
user_number.hasMany(models.emailSign, {
foreignKey: 'user_number_id',
onDelete: "CASCADE",
});
}
}
});
return user_number;
};
2- emailSign model
'use strict';
module.exports = function(sequelize, DataTypes) {
var emailSign = sequelize.define('emailSign', {
email: DataTypes.STRING,
user_number_id: DataTypes.INTEGER
}, {
underscored: true,
classMethods: {
associate: function(models) {
// associations can be defined here
emailSign.belongsTo(models.user_number, {
foreignKey: 'user_number_id',
})
}
}
});
return emailSign;
};
I Want distroy user_number casscade Remove emailSign my code for distroy is
User_number.distroy({where:{id : 5}}).then(function(){
resp.status(200);
)
user_number with id 5 is Remove But emailSign dont remove I How can Remove casscade emailSign??
m
via majid
No comments:
Post a Comment