Exql.Query

Summary

Functions

Wraps Exql.Sql.contruct/1 and adds resulting SQL to the Query

Connects to the database, executes the given query and returns the results

Defines the where clause of your query

Specify that you want to return a specific scope from the query, while returing all rows

Specify that you want to return the first row from the query with the given scope

Specify that you want to return the last row from the query with the given scope

Specify that you want to return a single row from the query with the given scope

Outlines the table or view you want to query

Functions

build_sql(query)

Wraps Exql.Sql.contruct/1 and adds resulting SQL to the Query.

execute(query)

Connects to the database, executes the given query and returns the results.

Example:

result =
  with("people")
  |> execute
filter(query, criteria, params)

Defines the where clause of your query.

Example:

result =
  with("people")
  |> filter("id = @id", [id: 1])
  |> execute
return(query, columns \\ "*")

Specify that you want to return a specific scope from the query, while returing all rows.

Example:

result =
  with("people")
  |> return("name")
  |> execute
return_first(query, columns \\ "*")

Specify that you want to return the first row from the query with the given scope.

This returns the full resultset and picks the first element from the list.

Example:

result =
  with("people")
  |> return_first("name")
  |> execute
return_last(query, columns \\ "*")

Specify that you want to return the last row from the query with the given scope.

This returns the full resultset and picks the last element from the list.

Example:

result =
  with("people")
  |> return_last("name")
  |> execute
return_single(query, columns \\ "*")

Specify that you want to return a single row from the query with the given scope.

This will also apply a TOP 1 statement to the resulting SQL statement.

Example:

result =
  with("people")
  |> return_single("name")
  |> execute
with(table)

Outlines the table or view you want to query.

Example:

result =
  with("people")
  |> execute