我想使用 Sequelize 迁移来更新 Postgres 数据库中的表。
我的 SQL 查询使用?Postgres 中的 de 运算符来处理 JSONB 列。
我需要运行的 SQL 查询是:
UPDATE messages SET type = 'products' WHERE type = 'gallery' and content ? '%textMain%'
Run Code Online (Sandbox Code Playgroud)
我在 Sequelize 中的迁移如下所示:
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.bulkUpdate(
'messages',
{ type: 'products' },
// HERE GOES THE WHERE CLAUSE
)
},
down: async (_queryInterface, _Sequelize) => {
}
};
Run Code Online (Sandbox Code Playgroud)