thevahidal / soul

🕉 A SQLite REST and realtime server
https://thevahidal.github.io/soul/
MIT License
1.45k stars 50 forks source link

Enhance API to Support Multiple IDs in a Single Filter Parameter #131

Closed TahaKhanAbdalli closed 11 months ago

TahaKhanAbdalli commented 11 months ago

Is your feature request related to a problem? Please describe. The current version of the API only supports filters with single values, as demonstrated by the following URL: http://localhost:8000/api/tables/customers/rows?_filters=CustomerId:1,country:Germany&_limit=100&_ordering=-id&_page=1. This limitation prevents the use of multiple IDs in a single filter parameter.

Describe the solution you'd like I propose enhancing the API's filtering capability to allow the use of multiple IDs within a single filter parameter. This would enable users to query data using an array of attributes such as IDs, as demonstrated in the following URL format: http://localhost:8000/api/tables/customers/rows?_filters=CustomerId:[1,2,3,4,5],country:Germany&_limit=100&_ordering=-id&_page=1 OR http://localhost:8000/api/tables/customers/rows?_filters=CustomerId:1,2,3,4,5,country:Germany&_limit=100&_ordering=-id&_page=1 (comma separated).

Or, multiple non-PK fields could be provided: http://localhost:8000/api/tables/customers/rows?_filters=country:Germany,France&_limit=100&_ordering=-id&_page=1

Describe alternatives you've considered As an alternative, users could currently achieve similar results by making multiple API calls with individual ID filter values. However, this approach may lead to increased API usage and potentially slower data retrieval times, particularly when dealing with a substantial number of IDs. The other way is users can make the call as: http://localhost:8000/api/tables/customers/rows/1,2,3,4,5 but this is limited to only PKs and not any other attribute.

Additional context In scenarios where users need to retrieve data related to multiple specific IDs, such as the example URL provided, the ability to pass an array of IDs within a single filter parameter can significantly enhance the efficiency and effectiveness of data retrieval. This feature would contribute to an improved user experience and provide users with a more powerful querying tool within the application's API.