如何通过 knex.js select for json mssql?
How to select for json mssql via knex.js?
是否可以通过 knex 为 json auto 类型定义 select ?
如何转换:
select *
from table1 t1
left join table2 t2 on t1.id = t2.t1_id
for json auto
进入knex.js语法?
这是正确的方法(knex 0.21.1 及更早版本):
const result = await knex.raw("?? for json auto", [
knex.select()
.from('table1 as t1')
.leftJoin('table2 as t2', 't1.id', 't2.t1_id')
]);
是否可以通过 knex 为 json auto 类型定义 select ?
如何转换:
select *
from table1 t1
left join table2 t2 on t1.id = t2.t1_id
for json auto
进入knex.js语法?
这是正确的方法(knex 0.21.1 及更早版本):
const result = await knex.raw("?? for json auto", [
knex.select()
.from('table1 as t1')
.leftJoin('table2 as t2', 't1.id', 't2.t1_id')
]);