title: how can i search database table with latitude and longitude using sequelize
body: <p>I have a store table that has a column lat_long which stores each store latitude/longitude as geometry point in sequelize. I want to be searching for stores based on proximity of the latitude/longitude from the request body from the front end. Have tried to exploit many related topics(answer) concerning this in Stackoverflow but what have learned is that the query can be written like this.</p>
  
  <pre><code>const location = sequelize.literal(`ST_GeomFromText('POINT(${lng} ${lat})', 4326)`);
  
      User.findAll({
        attributes: [[sequelize.fn('ST_Distance_Sphere', sequelize.literal('geolocation'), location),'distance']],
        order: 'distance',
        limit: 10,
        logging: console.log
      })
      .then(function(instance){
        console.log(instance);
      })
  </code></pre>
  
  <p>Have tried it and it works fine but the challenge am having is that; in this example and almost all the sample I saw sofar they made use of the attribute which return only distance but I want to return all the fields in the table. Then I tried removing the attribute then the response I got was not searched based on the geometry(distance) and I also tried to use where but am getting an error.</p>
  
  <p>Shown below is my latest query which is returning error please how can I go about this? thank you.</p>
  
  <pre><code>export const getNearestStoreWithCategory = async (lat, long) =&gt; {
    try {
      const location = sequelize.literal(`ST_GeomFromText('POINT(${lat} ${long})')`);
      const distance = sequelize.fn('ST_Distance_Sphere', sequelize.literal('lat_long'), location)
      const storeArr = await Store.findAll({
        order: distance,
        where: sequelize.where(distance),
        limit: 20
      })
      return storeArr
    } catch (error) {
      return error
    }
  }
  </code></pre>