当前位置: 首页 > 工具软件 > knex.js > 使用案例 >

Knex.js (NodeJS orm 框架)

沈曜灿
2023-12-01

官网:https://knexjs.org/
其他:https://blog.csdn.net/liuyueyi1995/article/details/53782047

笔记
1.knex.raw 处理特殊字段,根据 json 类型某个值进行排序

// training_area : {"city_id": 1, "area_id": 2}
//select * from reservation order by  training_area::Json ->> 'city_id' asc
knex('reservation').select('training_area').orderBy(knex.raw("training_area::json ->> 'city_id'"), 'desc')
    .then(data => console.log(data))
 类似资料: