cake/insert
A DSL to build INSERT queries.
Types
pub type InsertColumns =
write_query.InsertColumns
pub type InsertConflictStrategy(a) =
write_query.InsertConflictStrategy(a)
pub type InsertIntoTable =
write_query.InsertIntoTable
pub type InsertSource(a) =
write_query.InsertSource(a)
pub type InsertValue =
write_query.InsertValue
pub type WriteQuery(a) =
write_query.WriteQuery(a)
Functions
pub fn bool(value vl: Bool) -> InsertValue
Create an InsertValue from a column String and a Bool value.
pub fn columns(
insert isrt: 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 encoder function returns or is given as source
values.
pub fn comment(
insert isrt: Insert(a),
comment cmmnt: String,
) -> Insert(a)
Specify a comment for the INSERT query.
pub fn epilog(
insert isrt: Insert(a),
epilog eplg: String,
) -> Insert(a)
Specify an epilog for the INSERT query.
pub fn float(value vl: Float) -> InsertValue
Create an InsertValue from a column String and a Float value.
pub fn from_records(
table_name tbl_nm: String,
columns cols: List(String),
records rcrds: List(a),
encoder encdr: fn(a) -> InsertRow,
) -> Insert(a)
Create an INSERT query from a list of gleam records.
The encoder function is used to convert each record into an InsertRow.
pub fn from_values(
table_name tbl_nm: String,
columns cols: List(String),
values vls: List(InsertRow),
) -> Insert(a)
Create an INSERT query from a list of InsertRows.
pub fn get_columns(insert isrt: Insert(a)) -> InsertColumns
Get the columns to insert into from an Insert query.
pub fn get_comment(insert isrt: Insert(a)) -> Comment
Get the comment from an INSERT query.
pub fn get_epilog(insert isrt: Insert(a)) -> Epilog
Get the epilog from an INSERT query.
pub fn get_modifier(insert isrt: Insert(a)) -> String
Get the modifier from an Insert query.
pub fn get_on_conflict(
insert isrt: Insert(a),
) -> InsertConflictStrategy(a)
Get the conflict strategy from an Insert query.
pub fn get_source(insert isrt: Insert(a)) -> InsertSource(a)
Get the source from an Insert query which is either a list of records,
accompanied by a encoder function or a list of InsertRows.
pub fn get_table(insert isrt: Insert(a)) -> InsertIntoTable
Get the table name to insert into from an Insert query.
pub fn int(value vl: Int) -> InsertValue
Create an InsertValue from a column String and an Int value.
pub fn modifier(
insert isrt: Insert(a),
modifier mdfr: String,
) -> Insert(a)
Specify a modifier for the INSERT query.
pub fn no_comment(insert isrt: Insert(a)) -> Insert(a)
Specify that no comment should be added to the INSERT query.
pub fn no_epilog(insert isrt: Insert(a)) -> Insert(a)
Specify that no epilog should be added to the INSERT query.
pub fn no_modifier(insert isrt: Insert(a)) -> Insert(a)
Specify that no modifier should be used for the given INSERT query.
pub fn no_returning(insert isrt: Insert(a)) -> Insert(a)
Specify that no columns should be returned after the INSERT query.
pub fn on_columns_conflict_ignore(
insert isrt: Insert(a),
columns 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(
insert isrt: Insert(a),
columns 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(insert isrt: 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(
insert isrt: 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(
insert isrt: 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 returning(
insert isrt: Insert(a),
returning rtrn: List(String),
) -> Insert(a)
Specify the columns to return after the INSERT query.
pub fn row(values vls: List(InsertValue)) -> InsertRow
Create an InsertRow from a list of InsertValues.
pub fn source_records(
insert isrt: Insert(a),
source rcrds: List(a),
encoder encdr: fn(a) -> InsertRow,
) -> Insert(a)
Specify the source records to insert.
pub fn source_values(
insert isrt: Insert(a),
source rws: List(InsertRow),
) -> Insert(a)
Specify the source values to insert.
pub fn string(value vl: String) -> InsertValue
Create an InsertValue from a column String and a String value.
pub fn table(
insert isrt: Insert(a),
table_name tbl_nm: String,
) -> Insert(a)
Specify the table to insert into.