我知道 Sequelize 不支持 postgresQL 的 updateOnDuplicate sequelize doc ,那么有解决办法吗?
是否可以通过“SQL命令”来实现。
最佳答案
新的 sequelize (v5) 包括所有方言的 updateOnDuplicate 功能
Fields to update if row key already exists (on duplicate key update)? (only supported by MySQL, MariaDB, SQLite >= 3.24.0 & Postgres >= 9.5). By default, all fields are updated.
在这里查看:Docs
你可以使用
model.bulkCreate(dataToUpdate, { updateOnDuplicate: ["user_id", "token", "created_at"] })
关于node.js - 为 postgresQL 续写 bulkCreate updateOnDuplicate?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55531860/