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
Post a Comment