caprese
caprese copied to clipboard
Add Support for Multiple Values in Filter
JSONAPI implementations may support multiple values for a filter to reduce the number of queries on the server side: http://jsonapi.org/recommendations/#filtering
GET /comments?filter[post_id]=1,2 HTTP/1.1
The resulting query should be an IN query in rails:
Comment.where(post_id: values).to_sql
=> SELECT * FROM comments where post_id IN(val1, va2)
SUPPORTED:
GET /comments?filter[attr][]=1&filter[attr][]=2 HTTP/1.1
NOT SUPPORTED:
GET /comments?filter[attr][0]=1&filter[attr][1]=2 HTTP/1.1
GET /comments?filter[post_id]=1,2 HTTP/1.1
Gonna leave this open because though I like the solution, I want to continually improve JSON API adherence