How to call PostGIS functions using Lucid ORM?

Hello,

I’ve got a database in PostgreSQL containing GeoData,
and I need to invoke PostGIS functions such as ST_AsGeoJSON, ST_AsText etc. using the lucid ORM but can’t seem to find a way around.

Can anybody provide me with any example or docs related to the issue ?

Thanks,


Opened a stackoverflow question thread as well.

Since PostGIS is quite specific there is no built in support for in in Lucid. You should go with Database.raw()
https://adonisjs.com/docs/4.1/query-builder#_raw_queries

Edit:
Just noticed @CrBast told same thing in StackOverflow earlier

1 Like

Alright thanks,
Raw queries just work fine, though it would be better if we could invoke db functions from ORM.

Problem is that there are quite a lot of DBs that are supported. All DBs have different special functions and several DBs can be extended with plugins to have some more functionality.

Supporting them all on ORM level will be too much. It would be like reinventing SQL and then keeping it updated constantly. It would be cool indeed, but it’s just unreal amount of work