notum-cz / strapi-plugin-location

This plugin allows users to create location inputs and store latitude and longitude values as geometry types in a PostGIS database. It also provides functionality to filter items based on their location.
MIT License
26 stars 13 forks source link

Location search is not working with entityService.findMany #193

Open anil1712 opened 6 months ago

anil1712 commented 6 months ago

Hi,

Everything is working fine with inbuilt api but when I am trying to apply the filter using custom api its not filtering the records based on location provided in query params. Here is my code snippet

const response = await strapi.entityService.findMany("api::my-custom-location.my-custom-location", {...ctx.query} );

Here is the URL

http://localhost:1337/api/restaurants?$location[coords]=49.200949303006055,16.623833585841673,5000

Thanks, Anil

anil1712 commented 6 months ago

@Ballonek can you please suggest me something regarding this?

omikulcik commented 5 months ago

Hi @anil1712, are you sure "coords" is also name of the field you are filtering by? It was just an example you are supposed to change that based on the name of your field

anil1712 commented 5 months ago

@omikulcik Yes I did change based on the app, but its not working, do you have any working example with Custom APIs?

sebspi commented 3 months ago

@omikulcik Same question from my side. How do we have to "configure" the filters when using the entity service.

await strapi.entityService.findMany('api::entity.entity',
      {
        filters: WHAT_TO_SET_HERE?
      }
    )

Can you provide an example here, please?

UPDATE I figured out, that your plugin is doing some work before entering the controller method (core controller). How can I apply these changes to a custom controller?