使用以下迁移脚本:
const rules = [
{ type: 'read', target: 'table1', service: 'admin', scope: 'self', field: 'id' },
{ type: 'read', target: 'table2', service: 'admin', scope: 'self', field: 'id' }
]
module.exports = {
up: (queryInterface, Sequelize) => {
rules.map(({ type, target, service }) => { console.log( type, target, service) })
return queryInterface.bulkUpdate(
'rules',
rules,
{[Sequelize.Op.or]: rules.map(({ type, target, service }) => { console.log( type, target, service); return {type, target, service} })},
).then(ids => {
console.log(ids);
})
},
我看到正在执行的sql:
Executing (default): UPDATE "rules" SET "0"=$1,"1"=$2 WHERE (("type" = $6 AND "target" = $7 AND "service" = $8) OR ("type" = $9 AND "target" = $10 AND "service" = $11) OR ("type" = $12 AND "target" = $13 AND "service" = $14) OR ("type" = $15 AND "target" = $16 AND "service" = $17) OR ("type" = $18 AND "target" = $19 AND "service" = $20))
哪个出现此错误:
ERROR: column "0" of relation "rules" does not exist
但是它如何使索引而不是实际的列名。