inaka / sumo_db

Erlang Persistency Framework
http://inaka.github.io/sumo_db/
Apache License 2.0
174 stars 37 forks source link

Improve `sumo:find_by` to make it more flexible – pagination/sorting params as options #307

Open cabol opened 7 years ago

cabol commented 7 years ago

Currently, when is needed to execute a query with sort params using find_by, you are forced to pass the pagination parameters as well. The proposal is to implement find_by/3:

-spec find_by(DocName, Conditions, Opts) -> Res when
  DocName    :: schema_name(),
  Conditions :: conditions(),
  Opts       :: #{atom() := term()},
  Res        :: [user_doc()].

There might be some common option like: limit, offset, etc., which will be defined and documented in sumo, but in general, each adapter could have its own options, and of course, they should be well documented.