-
Notifications
You must be signed in to change notification settings - Fork 323
Description
Right now, when you call the API with a where statement -
User.where(name: 'Josh')
The server sees the request like this:
https://www.example.com/api/users?name=Josh
This is all well and good but if you have a large model and want to be able to filter on ANY of the attributes, you would need to create a complex method to handle the filtering (i.e. loop through all attributes and compare to the querystring to see if one of the keys match).
It would be cleaner if we could wrap the where filters in a root level attribute, like filter or whatever we want. So this:
User.where(name: 'Josh')
would appear like this:
https://www.example.com/api/users?filter[name]=Josh
and in the code we can check to see if the filter param was passed and all and then act ONLY on the keys passed.