json-server
json-server copied to clipboard
or logic in filtering
In my db I have something like this:
[
{
"id": "89be578a-ef59-4cf2-96ca-5911bf95d959",
"count": 1
},
{
"id": "464e2921-2a44-4bfb-b533-89f2a75f8ba5",
"count": 5
},
{
"id": "111837ad-7b91-4fd3-b7c8-daa7b194e8fa",
"count": 6
},
{
"id": "111837ad-7b91-4fd3-b7c8-daa7b194e8fa",
"count": 8
},
{
"id": "111837ad-7b91-4fd3-b7c8-daa7b194e8fa",
"count": 10
}
]
And I would like to request like this
/connections?count=1&count_gte=8
and get items with count 1,8 and 10.
Currently it seems that json-server applies some kind of "and" logic and this request become mutually exclusive. As a result I get empty array
Proposal allow "or" request
@typicode what do you think about it?
I would love to see such an option! Maybe someone may fork this project #1219 ?
How would you define an "or" in the parameter?
Maybe with _or_: /connections?count=1_or_count_gte=8?
I can imagine something like this:
/connections?count=1&count_or_gte=8
Inspired by:
https://gt-tech.bitbucket.io/spring-data-querydsl-value-operators/README.html
https://gt-tech.bitbucket.io/spring-data-querydsl-value-operators/EXAMPLE_APPLICATION.html
I like. What about multiple fields? How is that done in spring? E.g.:
?idA=123_or_idB=123
Would be magic if can consider the Lucene or ElasticSearch syntax, it's really useful
How does the syntax look exactly?
Obviously it's add more complexity: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
Any updates on this?
Any updates on this?