Answer the question
In order to leave comments, you need to log in
How to correctly implement filtering in API requests?
Given:
Some records in the database, each of which has boolean properties A and B.
I want to allow the user to display sets
A + B
A + not B
not A + B not A + not
B
undefined A and B (in the database they are empty)
in any set, t .e. if the user asks for example (A+B) + (not A+B) + undefined , all three sets must be displayed.
The question is how to implement this in a GET request in order to unload this data in one request, and not according to the number of required sets, and so that if a third ... tenth similar property appears, it would not be necessary to break everything significantly?
While terrible things come to mind, something like pushing an array of arrays into a GET request, but I don’t know how :) Like Can you tell me
if there are any ideas, or how to implement this in a GET request?
Answer the question
In order to leave comments, you need to log in
Write a small DSL and pass it as text in the query GET parameter.
If you do not pay attention to the smell (don't ever do this), you can directly
GET /objects/?query=WHERE A AND B OR NOT A AND B OR A IS NULL OR B IS NULL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question