select count(*)::integer from mytable
How to do this properly with knexjs?
knex('mytable').select(knex.raw('count(*)::integer'))
A more elegant solution to the big integer as string issue is detailed in #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)
I updated it accordingly, using knex-postgis https://github.com/jfgodoy/knex-postgis/issues/20#issuecomment-312404336
Now the query: .select(st.asText('count(*)::integer'))
shows: column "count(*)::integer" does not exist
Using:
[email protected]
[email protected]
[email protected]
@sagidM knex.raw definitely exists. You just need to call it from configured knex instance, not from require('knex').raw. And about knex-postgis you should ask elsewhere.
Most helpful comment
A more elegant solution to the big integer as string issue is detailed in #387.