ArrestDB
ArrestDB copied to clipboard
Multiple Criteria
Cannot GET on multiple criteria.
I gave another approach in order to filter queries with multiple and more powerfull criterias (=, <=, >=, ...). You can have a look to https://github.com/ogizanagi/ArrestDB#api-design :
...
limit
(LIMIT x
SQL clause)
offset
(OFFSET x
SQL clause)where
(WHERE x
SQL clause)
- array of:
col
(colum to filter)op
(SQL operator (e.g '=', '>=', ...))value
(value to filter)
As it lacks a concrete example, here is how to construct your urls:
#Get customers created after 2014-08-13 12:15 and where lastname is Doe
GET http://api.example.com/customers/?where[0][col]=date_created&where[0][op]=>=&where[0][val]=2014-08-13 12:15&where[1][col]=lastname&where[1][op]==&where[1][val]=Doe
I only did that first for an urgent need, it is not the best approach nor implementation but you'll find in this fork:
- the multiple where clauses
- more powerfull criterias
- another output for collections, with more informations about the request (current limit, offser, count & total).
Feel free to use this code and/or submit a PR about a similar way to handle it.
Of course, it's great. But it will drastically increment the complexity of the current implementation. However, I'd like to see such a feature for this project if someone is willing to do so.