-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] Add ability to combine filters into OR arrangement #1417
Comments
Hey @IgnusG , |
Hi @salihozdemir, You can use discriminated unions for this. What you do is you define an extra OrFilter with something like: type OtherFilter = {
field: string;
operator: Exclude<Operators, "or">;
value: any;
}
type OrFilter = {
// we omit the field property here
operator: "or";
value: Filter[];
} And then you use unions to define the Filter as follows: type Filter = OrFilter | OtherFilter; Typescript can use type narrowing based on the operator after this. If the operator is "or" it knows we're dealing with an The important part on why this works here is that there is something that both types have (in our case the Hope this helps! 👍 |
@IgnusG 🥇 |
Hey @IgnusG , |
Is your feature request related to a problem? Please describe.
Would be awesome if it was possible to include a search all input which could technically be coded as several filters set to the same value. The problem is there is no way to tell the data provider how to combine these values (which ones are AND and which ones are OR). In some providers I've seen these filters just passed on with this being left up to them, for example strapi I think does an AND and if there are 2 filters with the same field it uses OR for those.
Describe the solution you'd like
It would be great if it was possible to include filters in a more complex arrangement that allows for OR constructions being passed to providers while searching, for example:
Here the query would look like
"age" == 20 AND ("title" == "Test" OR "description" == "Test")
This could be adopted gradually by data providers that support it (for example this would be possible in the Airtable Provider) and ignored by providers that don't.
Additional context
In the example on https://refine.dev/docs/guides-and-concepts/search/table-search/ this is solved with the
q
field but this must be available on the database.The text was updated successfully, but these errors were encountered: