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

filters, sorting, paging... #14

Open
serayuzgur opened this issue Apr 18, 2017 · 2 comments
Open

filters, sorting, paging... #14

serayuzgur opened this issue Apr 18, 2017 · 2 comments
Assignees
Milestone

Comments

@serayuzgur
Copy link
Owner

serayuzgur commented Apr 18, 2017

Field selection

  • Sometimes don’t need all attributes of a resource. Give the API consumer the ability to choose returned fields. This will also reduce the network traffic and speed up the usage of the API.

GET /cars?fields=manufacturer,model,id,color

Paging (Slice)

  • Add _offset and _limit (an X-Total-Count header is included in the response).

GET /cars?_offset=10&_limit=5

  • To send the total entries back to the user use the custom HTTP header: X-Total-Count.

  • Content-Range offset – limit / count.

    • offset: Index of the first element returned by the request.

    • limit: Index of the last element returned by the request.

    • count: Total number of elements in the collection.

  • Accept-Range resource max.

  • resource: The type of pagination. Must remind of the resource in use, e.g: client, order, restaurant, …

  • max : Maximum number of elements that can be returned in a single request.

Sorting

  • Allow ascending and descending sorting over multiple fields.
  • Use sort with underscore as _sort.
  • In code, descending describe as -, ascending describe as +.

GET /cars?_sort=-manufactorer,+model

Operators

  • Add _filter query parameter and continue with field names,operations and values separated by ,.
  • Pattern _filter=<fieldname><operation><value>.
  • Supported operations.
    • = equal
    • != not equal
    • < less
    • <= less or equals
    • > greater
    • >= greater or equals
    • ~= like
    • |= in (values must be separated with |

GET http://127.0.0.1:8080/robe/users?_filter=name=seray,active=true

Full-text search

  • Add _q.

GET /cars?_q=nissan

@serayuzgur serayuzgur added this to the 0.0.1-beta milestone Apr 18, 2017
@serayuzgur serayuzgur self-assigned this Apr 20, 2017
serayuzgur added a commit that referenced this issue Apr 20, 2017
serayuzgur added a commit that referenced this issue Apr 20, 2017
serayuzgur added a commit that referenced this issue May 4, 2017
serayuzgur added a commit that referenced this issue May 4, 2017
serayuzgur added a commit that referenced this issue May 5, 2017
serayuzgur added a commit that referenced this issue Aug 16, 2017
@kbukum
Copy link
Collaborator

kbukum commented Aug 16, 2017

I got error after some queries and application crashed.

Error Detail :
Some(Queries { fields: [], filter: [], q: None, paginate: (OFFSET(0), LIMIT(5)), slice: [], sort: [] })
paging LIMIT(5)
Some(Queries { fields: [], filter: [], q: None, paginate: (OFFSET(0), LIMIT(5)), slice: [], sort: [] })
thread 'main' panicked at 'called Result::unwrap() on an Err value: ErrorImpl { code: EofWhileParsingValue, line: 1, column: 0 }', src/libcore/result.rs:860
note: Run with RUST_BACKTRACE=1 for a backtrace.

Repository owner deleted a comment from kbukum Aug 16, 2017
Repository owner deleted a comment from kbukum Aug 16, 2017
Repository owner deleted a comment from kbukum Aug 16, 2017
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

2 participants