title: Best way to do something if map has keys in Elixir?
body: <p>So I'm trying to implement a query function for a Collection table. And that table HAS to be filtered by :id, but it CAN be also filtered by :rating and :accessibility.</p>
  
  <p>Right now I have a function that is something like this:</p>
  
  <pre><code>def find_collection(args) do...
  </code></pre>
  
  <p>Where args can be one of: <code>%{id: id}</code>, <code>%{id: id, rating: rating}</code>, <code>%{id: id, accessibility: accessibility}</code> or <code>%{id: id, rating: rating, accessibility: accessibility}</code>. And I need to make these in to ecto queries: <code>[id: id]</code>, <code>[id: id, rating: rating]</code>, etc...</p>
  
  <p>I know I can make 4 different functions that expect different <code>args</code>, but that seems very non-reusable. Maybe someone could give me a hit a better way to do composable "if map has key a do this and key b do this"?</p>