FatEcto.FatOrderBy (FatEcto v1.1.0)
View SourceBuilds query with asc
or desc
order.
This module provides functionality to dynamically add order_by
clauses to Ecto queries
based on the provided parameters. It supports various order formats, including $ASC
,
$DESC
, and nulls handling ($ASC_NULLS_FIRST
, $DESC_NULLS_LAST
, etc.).
Summary
Functions
Orders the results based on the order_by
clause in the params.
Functions
Orders the results based on the order_by
clause in the params.
Parameters
queryable
: Ecto Queryable that represents your schema name, table name, or query.order_by_params
: A map of fields and their order formats (e.g.,%{"field" => "$ASC"}
).opts
: Options related to query bindings.build_options
: Options related to the OTP app (unused in this function).
Examples
iex> query_opts = %{"$ORder" => %{"id" => "$ASC"}}
iex> FatEcto.FatOrderBy.build_order_by(FatEcto.FatHospital, query_opts["$ORder"], [], [])
#Ecto.Query<from f0 in FatEcto.FatHospital, order_by: [asc: f0.id]>