Open matronator opened 6 months ago
@matronator , it's because JSON Server doesn't natively support filtering based on date ranges out of the box.
JSON Server treats query parameters as string values, so when you use _gte, it's comparing the strings lexicographically rather than comparing them as dates. As a result, you're not getting the desired filtering effect.
Why does this say you can do it for dates?
Any idea how to make it work? Do I have to write some extension or save it as timestamps instead?
It seems to me that lexicographic comparison of strings is not working at all.
db.json
{ "days": [ { "id": 0, "data": "a" }, { "id": 1, "data": "b" }, { "id": 2, "data": "c" }, { "id": 3, "data": "d" }, { "id": 4, "data": "e" }, { "id": 5, "data": "f" }, { "id": 6, "data": "g" } ] }
URL: http://localhost:3000/days?data_gt=c
It is also an empty array.
DB file:
URL:
http://localhost:3000/days?date_gte=2024-03-01
Returns an empty array.