Struct ::exo::SqlQuery

Overview

Methods

fn new() -> SqlQuery

Creates a new empty SqlQuery This equals a sql query like SELECT * FROM *;

Example

let query = exo::SqlQuery::new();
assert!(query is exo::SqlQuery);

Return the SqlQuery as sql string.

Example

let query = exo::SqlQuery::new();
assert_eq!(query.to_string(), "SELECT * FROM *;");
fn parse_str(inp: String) -> Result

This function tries to parse the SqlQuery from a string.

Example

let query = exo::SqlQuery::parse_str("SELECT * FROM *;")?;
assert_eq!(query,exo::SqlQuery::new());

Clones the SqlQuery and returns a new independet one.

fn model(self, model: String) -> SqlQuery

Set one or multiple models to the SqlQuery. This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new().model("user").model("right");
assert_eq!(query.to_string(), "SELECT * FROM user, right;");
fn limit(self, limit: i64) -> SqlQuery

Set the limit of the SqlQuery. This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new().limit(10);
assert_eq!(query.to_string(), "SELECT * FROM * LIMIT 10;");
fn offset(self, offset: i64) -> SqlQuery

Set the offset of the SqlQuery. This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new().offset(10);
assert_eq!(query.to_string(), "SELECT * FROM * OFFSET 10;");
fn check(self, variable: String, operator: String, value) -> SqlQuery

Set an additonal check/where condition This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new().check("ident", "==", "test");
assert_eq!(query.to_string(), "SELECT * FROM * WHERE ident = \"test\";");
fn search(self, query: String) -> SqlQuery

Set a full text search query for the given language This functions consumes the SqlQuery and returns it updated. Also sets sort_by to none and sort_oder to desc.

Example

let query = exo::SqlQuery::new().search("Right");
fn column(self, column: String) -> SqlQuery

Set a specific column for the SqlQuery This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new().column("uuid");
assert_eq!(query.to_string(), "SELECT uuid FROM *;");
fn aggregate(self, column: String, function: String) -> SqlQuery

Set a specific aggregate column for the SqlQuery This functions consumes the SqlQuery and returns it updated. Aggregates can not be combined with normal columns.

Example

let query = exo::SqlQuery::new().aggregate("uuid", "count");
assert_eq!(query.to_string(), "SELECT COUNT(uuid) FROM *;");
fn aggregate_with_param(self, column: String, function: String, parameter: String) -> SqlQuery

Set a specific aggregate column with parameter for the SqlQuery This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new().aggregate_with_param("currency_col", "sum_currency_only", "CHF");
assert_eq!(query.to_string(), "SELECT SUM_CURRENCY_ONLY(currency_col, \"CHF\") FROM *;");
fn and(self, variable: String, operator: String, value) -> SqlQuery

Add an AND condition to the query This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new().and("name", "=", "John").and("age", ">", 18);
assert_eq!(query.to_string(), "SELECT * FROM * WHERE name = \"John\" AND age > \"18\";");
fn or(self, variable: String, operator: String, value) -> SqlQuery

Add an OR condition to the query This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new().and("status", "=", "active").or("priority", "=", "high");
assert_eq!(query.to_string(), "SELECT * FROM * WHERE status = \"active\" OR priority = \"high\";");
fn and_group(self, callback: Function) -> SqlQuery

Add a grouped set of conditions with AND chaining to the query This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new()
   .and_group(|q| q.and("a", "=", 1).and("b", "=", 2))
   .or("c", "=", 3);
// Produces: WHERE (a = "1" AND b = "2") OR c = "3"
fn or_group(self, callback: Function) -> SqlQuery

Add a grouped set of conditions with OR chaining to the query This functions consumes the SqlQuery and returns it updated.

Example

let query = exo::SqlQuery::new()
   .and("status", "=", "active")
   .or_group(|q| q.and("priority", "=", "high").or("urgent", "=", true));
// Produces: WHERE status = "active" OR (priority = "high" OR urgent = "true")
fn sort_by(self, sort_by) -> SqlQuery

Define the column by which the values should be sorted

fn sort_order(self, sort_order) -> SqlQuery

Define the sort oder (desc / asc)

Protocols

protocol get models
let output = value.models

Allows a get operation to work.

protocol set models
value.models = input

Allows a set operation to work.

protocol get limit
let output = value.limit

Allows a get operation to work.

protocol set limit
value.limit = input

Allows a set operation to work.

protocol get offset
let output = value.offset

Allows a get operation to work.

protocol set offset
value.offset = input

Allows a set operation to work.

protocol get columns
let output = value.columns

Allows a get operation to work.

protocol set columns
value.columns = input

Allows a set operation to work.

protocol get sort_by
let output = value.sort_by

Allows a get operation to work.

protocol set sort_by
value.sort_by = input

Allows a set operation to work.

protocol get sort_order
let output = value.sort_order

Allows a get operation to work.

protocol set sort_order
value.sort_order = input

Allows a set operation to work.

protocol partial_eq
if value == b { }

Allows for partial equality operations to work.

protocol string_debug
println("{:?}", value)

Allows the value to be debug printed.

protocol string_display
println("{}", value)

Allows the value to be display printed.