Skip to content
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

Multiple Criteria #9

Open
AlexHowardAlex opened this issue Apr 17, 2014 · 3 comments
Open

Multiple Criteria #9

AlexHowardAlex opened this issue Apr 17, 2014 · 3 comments

Comments

@AlexHowardAlex
Copy link

Cannot GET on multiple criteria.

@ogizanagi
Copy link

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.

@jslegers
Copy link

@ogizanagi & @alixaxel :

What are your thoughts about the OData URL conventions?

@ogizanagi
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants