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

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -