knex.js - Bookshelf.js relation for loosely related data -


i have hotel table, , amenity table. way "related" via location, using postgis postgresql. in sql use query find 5 nearest amenities hotel:

select amenity.name, amenity.brand, st_distance_sphere(hotel.geom, amenity.geom) amenity, hotel slug='city-plaza' order st_distance(hotel.geom, amenity.geom) limit 5;

is there way add "nearestamenities" field hotel model using bookshelf, collection of amenity?

have tried using knex.raw functionality?

knex.raw('select amenity.name, amenity.brand, ... limit 5').then(function(resp) {   ... }); 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -