Sequelize bulkCreate updateOnDuplicate for postgresQL?

Melroy Fernandes picture Melroy Fernandes · Apr 5, 2019 · Viewed 9.6k times · Source

I know there is no support for updateOnDuplicate for postgresQL by Sequelize sequelize doc, so is there a work around for this?

Can it be implemented via "SQL command".

Answer

sawim picture sawim · Apr 5, 2019

There is some work around. See upsert function. When used in Postgresql it creates custom function in database. Unfortunately there is no bulkUpsert, so you either use it in some for-loop or execute raw SQL as suggested here.