Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: PostGIS query with NodeJS, BookshelfJS and Knex

Matteo:

I'm on a project with NodeJS, BookshelfJS and ExpressJS. My database is Postgres with Postgis installed. My table 'organizations' has a 'lat_lon' geometry column. I would like to query all the Organization within a fixed radius of a specific lat/long point. I tried something like this:


var organizations = await Organization.query(function (qb) {
qb.where('ST_DWithin(lat_lon, ST_GeomFromText("POINT(45.43 10.99)", 4326), 1000 )')
}).fetchAll()

and more combinations but it doesn't work. It returns me an error

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: The operator "undefined" is not permitted

It seems it is expecting the operator inside the where condition but I'm already working on the 'lat_lon' column.

How can I fix it? Thanks



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: PostGIS query with NodeJS, BookshelfJS and Knex

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×