Here I am updating user_features
in database and I found from here that I can Bulk update through updateOnDuplicate:
But it's throwing error like below
SequelizeDatabaseError: syntax error at or near ")"
I have tried updateOnDuplicate: true
but it only supports in mysql not in postgresql
var feature_body_list = [];
for (let index = 0; index < req.body.features.length; index++) {
let feature_body = {
user_id: req.body.id,
feature_id: req.body.features[index]
}
feature_body_list.push(feature_body);
}
await sequelize.user_features.bulkCreate(feature_body_list, { updateOnDuplicate: ["user_id", "feature_id"] });
but when I remove updateonDuplicate it works perfectly and throws UniqueConstraintError duplication of key so, how can I bulk update ???