View Source ExtractQueryParams (extract_query_params v0.1.0)

Module for extracting query parameters from a list of keywords.

Summary

Functions

Turns list of keywords to SQL statement variables, connected with an operator (defaults to "AND").

Turns list of keywords to SQL statement variables, connected with an operator (defaults to "AND"). Raises an ArgumentError if the logical operator is not supported.

Functions

@spec to_variables([keyword()]) :: {binary(), [any()]}

Turns list of keywords to SQL statement variables, connected with an operator (defaults to "AND").

Examples

iex> ExtractQueryParams.to_variables(foo: "bar")
{"foo = ?", ["bar"]}
Link to this function

to_variables(keywords, logical_operator)

View Source
@spec to_variables([keyword()], binary()) :: {binary(), any()}
Link to this function

to_variables!(keywords, logical_operator)

View Source
@spec to_variables!([keyword()], binary()) :: {binary(), [any()]}

Turns list of keywords to SQL statement variables, connected with an operator (defaults to "AND"). Raises an ArgumentError if the logical operator is not supported.

Examples

iex(1)> ExtractQueryParams.to_variables!([foo: "foo", bar: "bar"], "AND")
{"foo = ? AND bar = ?", ["foo", "bar"]}

iex(2)> ExtractQueryParams.to_variables!([foo: "foo", bar: "bar"], "UNSUPPORTED")
** (ArgumentError) logical operator "UNSUPPORTED" is not supported.