How to update array of objects with same value in reference_id (FK Column) in Sequelize JS?

You should execute all updates in the same transaction (to avoid inconsistencies in DB):

sequelize.transaction(async transaction => {
  const options = req.body;
  for (const option of options) {
    await db.Option.update(option, {
        where: { question_id: req.params.id },
         transaction
      });
  }
}).then(...

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top