问题描述
我正在尝试向 Geography 列添加一个方法调用 ST_ASText,以将其转换回 wkt。所以我尝试做这样的事情。
activeTrx(TABLE_NAME)
.returning(['id','ST_AsText(polygon_wkt)')
.insert(values);
解决方法
Afaik 应该可以,但您需要使用 knex.raw
activeTrx(TABLE_NAME)
.returning([
'id',knex.raw('ST_AsText(??)',['polygon_wkt'])
])
.insert(values);
,
我最终做了这样的事情。这奏效了。
activeTrx
.raw(
`?
RETURNING id,ST_AsText(polygon_wkt) as polygon_wkt;`,[activeTrx.table(TABLE_NAME).insert(values)],)
.then((result) => {
return result.rows;
});