cake/query/insert
A DSL to build INSERT
queries.
Functions
pub fn columns(
query qry: Insert(a),
columns cols: List(String),
) -> Insert(a)
Specify the columns to insert into.
NOTICE: You have to specify the columns and keep track if their names are
correct, as well as their count which must be equal to the count of
InsertRows
the caster function returns or is given as source
values.
pub fn from_records(
table_name tbl_nm: String,
columns cols: List(String),
records rcrds: List(a),
caster cstr: fn(a) -> InsertRow,
) -> Insert(a)
Create an INSERT
query from a list of gleam records.
The caster
function is used to convert each record into an InsertRow
.
pub fn from_values(
table_name tbl_nm: String,
columns cols: List(String),
records rcrds: List(InsertRow),
) -> Insert(a)
Create an INSERT
query from a list of InsertRow
s.
pub fn get_modifier(query qry: Insert(a)) -> String
pub fn no_comment(query qry: Insert(a)) -> Insert(a)
pub fn no_modifier(query qry: Insert(a)) -> Insert(a)
pub fn no_returning(query qry: Insert(a)) -> Insert(a)
pub fn on_columns_conflict_ignore(
query qry: Insert(a),
column cols: List(String),
where whr: Where,
) -> Insert(a)
This specifies that specific conflicts do not result in an error but instead are just ignored and not inserted.
Conflict Target: Columns
pub fn on_columns_conflict_update(
query qry: Insert(a),
column cols: List(String),
where whr: Where,
update updt: Update(a),
) -> Insert(a)
Inserts or updates on conflict, also called ´.UPSERT´.
Conflict Target: Columns
pub fn on_conflict_error(query qry: Insert(a)) -> Insert(a)
This specifies that any conflicts result in the query to fail
This is the default behaviour.
pub fn on_constraint_conflict_ignore(
query qry: Insert(a),
constraint cnstrt: String,
where whr: Where,
) -> Insert(a)
This specifies that specific conflicts do not result in an error but instead are just ignored and not inserted.
Conflict Target: Constraint
pub fn on_constraint_conflict_update(
query qry: Insert(a),
constraint cnstrt: String,
where whr: Where,
update updt: Update(a),
) -> Insert(a)
Inserts or updates on conflict, also called ´.UPSERT´.
Conflict Target: Constraint
pub fn source_records(
query qry: Insert(a),
source rcrds: List(a),
caster cstr: fn(a) -> InsertRow,
) -> Insert(a)
pub fn source_values(
query qry: Insert(a),
records rcrds: List(InsertRow),
) -> Insert(a)