vt-elixir / ja_resource

A behaviour to reduce boilerplate code in your JSON-API compliant Phoenix controllers without sacrificing flexibility.
Other
113 stars 33 forks source link

Better description for filter/4 in README for dash/snake case? #38

Closed johnmosesman closed 6 years ago

johnmosesman commented 8 years ago

Hello again!

I figured this out through experimentation, but for clarity do you think in the filter section of the README there should be something describing the dash-to-underscore transition?

For example I set up my filter function like this:

http://localhost:4000/api/posts?filter[user-id]=1

def filter(_conn, query, "user-id", user_id) do
  where(query, user_id: ^user_id)              
end                                                      

And it wasn't being called. Didn't realize "user-id" was "user_id" when it hit filter/4.

If you disagree feel free to close!

alanpeabody commented 8 years ago

Sure, to be clear all param keys are formatted by JaSerializer in the manner you have configured (by default this is expecting dashes to be converted to underscores).

An Update to the README would be most welcome!