Closed mathislucka closed 1 year ago
@mathislucka thanks for the PR. This is an interesting concept.
So If i understand correctly,
apiParams.addFilter("pet", "cat")
can be also written as,
apiParams.addFilterQuery("pet = 'cat'")
apiParams.addFilter("name", "Jo", "CONTAINS", "first-name")
can be also written as,
apiParams.addFilterQuery("name CONTAINS 'Jo' memberOf first-name")
Following complications spring to my mind immediately:
IS NULL
)Am trying to introduce placeholder support in upcoming release. After that I might pickup this feature request https://github.com/d34dman/drupal-jsonapi-params/issues/6 which lets you create DrupalJsonApiParams obj from previously encoded query object. I will keep this PR in mind, so that something like this could be introduced (but making no promises atm).
Yes, your understandig is correct.
I understand your concerns but I think I addressed these complications:
apiParams.addFilterQuery("date BETWEEN '[ 2020, 2021 ]'")
If the user does not pass the right amount of parameters or they have the wrong format an error will be thrown because addFilterQuery
calls addFilter
internally.
This has been in the backlog for a while and am moving to won't fix. I feel this could be a different library that can depend on drupal-jsonapi-params and achieve the results. (With separate readme and features/bug tracking).
This implements a method allowing filters to be constructed from query strings.
It should mainly be more convenient and quicker to type for less complex filters.
Query strings can be written like so: