5

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 ???

Aryan
  • 3,338
  • 4
  • 18
  • 43

1 Answers1

3

Try To update your Sequelize.js Version to latest version. I think it will solve your problem. I have also faced same error I have updated my Sequelize.js version to latest version

any
  • 88
  • 5