ArrestDB icon indicating copy to clipboard operation
ArrestDB copied to clipboard

Multiple Criteria

Open AlexHowardAlex opened this issue 10 years ago • 3 comments

Cannot GET on multiple criteria.

AlexHowardAlex avatar Apr 17 '14 11:04 AlexHowardAlex

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.

ogizanagi avatar Jan 13 '15 18:01 ogizanagi

@ogizanagi & @alixaxel :

What are your thoughts about the OData URL conventions?

jslegers avatar Feb 23 '15 15:02 jslegers

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.

ogizanagi avatar Feb 23 '15 15:02 ogizanagi