tiny_ecto_helper_mysql v1.0.1 TinyEctoHelperMySQL View Source

Documentation for TinyEctoHelperMySQL

Link to this section Summary

Functions

get columns lists in queryable

Examples

Issue query to MySQL with queryable AND SELECT SQL_CALC_FOUND_ROWS, then return the result and the count returned from SELECT FOUND_ROWS() like following

Link to this section Functions

get columns lists in queryable

from( q in Question, select: {q.id, q.title, q.body} ) |> TinyEctoHelperMySQL.get_select_keys() | | | [:id, :title, :body]

Link to this function query_and_found_rows(query, keys, list) View Source

Examples

Issue query to MySQL with queryable AND SELECT SQL_CALC_FOUND_ROWS, then return the result and the count returned from SELECT FOUND_ROWS() like following:

query = from(

q in Question,
select: {q.id, q.title, q.body, q.user_id, q.inserted_at, q.updated_at},
order_by: [asc: q.id]

)

{:ok, select_keys} = TinyEctoHelperMySQL.get_select_keys(query) TinyEctoHelperMySQL.query_and_found_rows(query, select_keys, [Repo, %Question{}, Question]) | | | {:ok, %{results: results, count: count}}