Skip to content
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

Add "or" operator handler for refine filters #2

Closed

Conversation

salihozdemir
Copy link

Hey @rturan29 ,

refine will soon release a version that will add support for the or operator for filtering. With the new version, CrudFilters will consist of two separate union types, so the getFilterQuery function will need to handle these two types.

The user will can create a filter as follows:

filter = [
    {
      operator: "eq",
      field: "age",
      value: 20
    },
    {
      operator: "or",
      value: [
        {
          field: "title",
          operator: "eq",
          value: "Test",
        },
        {
          field: "description",
          operator: "eq",
          value: "Test"
        }
      ]
   }
]

Here the query would look like "age" == 20 AND ("title" == "Test" OR "description" == "Test")

The field property will can be undefined so I made a small change to the your getFilterQuery function. When refine releases the new version, you can make some changes on this PR to add "or" operator support.

You can check out the PR for more information about the new release.

If you need any help, feel free to reach out to me on discord.
Happy coding!

@resulturan resulturan closed this Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants