+ def fetch_paginated(query, %{"total" => true} = params, :offset) do
+ total = Repo.aggregate(query, :count, :id)
+
+ %{
+ total: total,
+ items: fetch_paginated(query, Map.drop(params, ["total"]), :offset)
+ }
+ end
+
+ def fetch_paginated(query, params, :offset) do
+ options = cast_params(params)
+
+ query
+ |> paginate(options, :offset)
+ |> Repo.all()
+ end
+
+ def paginate(query, options, method \\ :keyset)
+
+ def paginate(query, options, :keyset) do