cake/query/insert

A DSL to build INSERT queries.

Functions

pub fn bool(value vl: Bool) -> Param
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 comment(
  query qry: Insert(a),
  comment cmmnt: String,
) -> Insert(a)
pub fn float(value vl: Float) -> Param
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 InsertRows.

pub fn get_modifier(query qry: Insert(a)) -> String
pub fn get_table(query qry: Insert(a)) -> String
pub fn int(value vl: Int) -> Param
pub fn modifier(
  query qry: Insert(a),
  modifier mdfr: String,
) -> Insert(a)
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 param(column col: String, param prm: Param) -> InsertValue
pub fn returning(
  query qry: Insert(a),
  returning rtrn: List(String),
) -> Insert(a)
pub fn row(a: List(InsertValue)) -> InsertRow
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)
pub fn string(value vl: String) -> Param
pub fn table(
  query qry: Insert(a),
  table_name tbl_nm: String,
) -> Insert(a)
pub fn to_query(insert: Insert(a)) -> WriteQuery(a)
Search Document