View Source Bind (bind v0.14.0)

Summary

Functions

Turns a query from query/3, with any scopes piped after it, into one that selects how many rows it matches: the filters, joins and cursor stay, sort, limit and preloads drop. Run it with Repo.one/1.

Whether the params ask for the number of matching rows: count=true (or 1). count is a reserved key like sort, limit and start.

Merges additional filters with existing query params.

Maps over query parameters, letting you transform values by pattern matching field names.

Maps over query parameters with error handling. Returns {:ok, mapped_params} on success or {:error, reason} on failure.

Builds an Ecto query for the given schema based on the provided parameters.

Functions

Turns a query from query/3, with any scopes piped after it, into one that selects how many rows it matches: the filters, joins and cursor stay, sort, limit and preloads drop. Run it with Repo.one/1.

The cursor (start, -start) is a where on id, so with one the count is the rows past it and shrinks as a client pages. The listing's total comes from the first page, which has no cursor.

The query is counted as a subquery, so a scope's distinct, group_by or select never changes the number.

Whether the params ask for the number of matching rows: count=true (or 1). count is a reserved key like sort, limit and start.

Link to this function

filter(query_string, filters)

View Source

Merges additional filters with existing query params.

Link to this function

map(query_string, field_mappers)

View Source

Maps over query parameters, letting you transform values by pattern matching field names.

Link to this function

map_safe(query_string, field_mappers)

View Source

Maps over query parameters with error handling. Returns {:ok, mapped_params} on success or {:error, reason} on failure.

Link to this function

query(params, schema, opts \\ [])

View Source

Builds an Ecto query for the given schema based on the provided parameters.