[英]Multiple rows update in one statement with Knex
I trying to update multiple rows in one statement with following syntax:我尝试使用以下语法在一个语句中更新多行:
update test as t set
column_a = c.column_a,
column_c = c.column_c
from (values
('123', 1, '---'),
('345', 2, '+++')
) as c(column_b, column_a, column_c)
where c.column_b = t.column_b;
How can I do it with Knex?我怎样才能用 Knex 做到这一点? Or only one way is to use pg-node prepared statements?
还是只有一种方法是使用 pg-node 准备好的语句?
AFAK knex doesn't have any tools to help with this kind of query. AFAK knex 没有任何工具可以帮助进行此类查询。 Though you can do it by using
knex.raw()
.尽管您可以使用
knex.raw()
来做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.