Answer the question
In order to leave comments, you need to log in
Automatic update of id when deleting email. with bd. How to write logic?
Hello everyone, can anyone tell me, through sequilize I set it to be added to the table that is in the db autoIncrement: true , then when adding each element id is more by one, how can I make sure that when this element is deleted id "zeroed" then if y I have 3 emails in the table : id : 2 , id : 3 , id : 4
then after deleting the email. with id : 4 , when creating a subsequent email . its id was 4 . Now id is added without difference on deletion, also after deletion of id: 4 next. email will have id : 5 . Here's how I described the model.
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
name: { type: DataTypes.STRING, unique: true, allowNull: false },
async delete(req, res) {
const id = req.params.id;
await Type.destroy({
where: {
id: id,
},
});
const types = await Type.findAll();
return res.json(types);
}
Answer the question
In order to leave comments, you need to log in
What you are asking is absolutely wrong. This is the same as if, after the death of one person, to change the passport numbers of all the survivors.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question