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 query operators to json api #74
Conversation
Hello Sergio, I can't accept this patch: I don't think it is jsonapi compliant, is it? class MyClass(SAFRSBase, db.Model):
...
jsonapi_filter = your_jsonapi_filter There are other ways to implement custom queries:
Can you work with this? |
wait, I think I misunderstood your code and explanation. |
Hey Thomas,
I totally understand. I wasn't aware of jsonapi, let's drop this and I
will try and come up with a solution after reading more on jsonapi.
BR,
Sergio.
…On Sun, 30 Aug 2020 at 11:56, Thomas Pollet ***@***.***> wrote:
Hello Sergio,
I can't accept this patch: I don't think it is jsonapi compliant, is it?
If you want to implement this in your code, you can set the jsonapi_filter
method of your model, for ex.
class MyClass(SAFRSBase, db.Model):
...
jsonapi_filter = your_jsonapi_filter
There are other ways to implement custom queries:
- using a SAFRSBase._s_filter override, which will be called with the
filter= url query arguments.
- using a jsonapi_rpc decorator
Can you work with this?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#74 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACZR7LGM6SMJHKYIMVYP2I3SDIV4NANCNFSM4QPRLPZA>
.
|
Will come up with better solution |
Well, I've been thinking about implementing better filtering but I didn't have the time to implement one. The jsonapi spec is quite liberal regarding filtering strategies https://jsonapi.org/recommendations/#filtering . A bit too liberal imho. If you manage to implement something generic, I'd be very happy to merge it. There were some ideas here : https://discuss.jsonapi.org/t/share-propose-a-filtering-strategy/257/8 , but no consensus afaik :( . |
Yes I was looking at exactly that thread, already has some better
suggestions in terms of syntax. :)
…On Sun, 30 Aug 2020 at 12:43, Thomas Pollet ***@***.***> wrote:
Well,
I've been thinking about implementing better filtering but I didn't have
the time to implement one. The jsonapi spec is quite liberal regarding
filtering strategies https://jsonapi.org/recommendations/#filtering . A
bit too liberal imho.
If you manage to implement something generic, I'd be very happy to merge
it. There were some ideas here :
https://discuss.jsonapi.org/t/share-propose-a-filtering-strategy/257/8 ,
but no consensus afaik :( .
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#74 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACZR7LDDDXRCWIVI35ZBRO3SDI3OTANCNFSM4QPRLPZA>
.
|
I haven't used it, but Drupal seems to have pretty solid jsonapi filtering too: https://www.drupal.org/docs/core-modules-and-themes/core-modules/jsonapi-module/filtering |
It seems this style of using brackets [] is called simple filters which
according to
https://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html only
supports the "eq" operator. BTW that package does have the functionality I
am looking for so I will see what work is needed to integrate it, if any.
…On Sun, 30 Aug 2020 at 12:54, Thomas Pollet ***@***.***> wrote:
I haven't used it, but Drupal seems to have pretty solid jsonapi filtering
too:
https://www.drupal.org/docs/core-modules-and-themes/core-modules/jsonapi-module/filtering
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#74 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACZR7LDRZY7NWRWJBGX2SJLSDI4YFANCNFSM4QPRLPZA>
.
|
Hi Tomaxx,
I don't know if this can be done already as I didn't go through the code thoroughly.
I want to be able to query stuff based on ranges. For instance if I have a timestamp field and I want to query a range with this patch you can do a GET for instance to
http://localhost:5000/?filter[timestamp]=>2020-08-01and<2020-08-03
to retrieve entries between those 2 dates.This patch allows 2 types of queries:
Where op can be <,<=,>,>=
Where op1 and op2 are like op. And bop is one of "and", "or".
Please share your opinion.