select count(*)::integer from mytable
如何使用 knexjs 正确执行此操作?
knex('mytable').select(knex.raw('count(*)::integer'))
#387 中详细介绍了大整数作为字符串问题的更优雅的解决方案。
@rhys-vdw global Knex.raw is deprecated, use knex.raw (chain off an initialized knex object)
(https://github.com/jfgodoy/knex-postgis/issues/20)
我相应地更新了它,使用knex-postgis
https://github.com/jfgodoy/knex-postgis/issues/20#issuecomment -312404336
现在查询: .select(st.asText('count(*)::integer'))
显示: column "count(*)::integer" does not exist
@sagidM knex.raw
肯定存在。 您只需要从配置的 knex 实例调用它,而不是从require('knex').raw
调用它。 关于knex-postgis
你应该在别处问。
最有用的评论
#387 中详细介绍了大整数作为字符串问题的更优雅的解决方案。