← all modules

Std.Db.Table

Std.Db.Table
  Std.Db.Table — a reflection-based record↔row mapper (Layer 3 Sky source).

Types
  type Table = Table_OPAQUE

Values
  all : Db -> Table a -> Task Error (List a)
      Every row, decoded into records.
  codec : String -> (v -> String) -> (String -> v) -> Table a -> Table a
      Custom column codec for any field type — encode to a String, decode back.
  createTable : Db -> Table a -> Task Error ()
      Create the table — dialect-correct DDL derived from the record + the
  delete : Db -> Table a -> String -> p -> Task Error Int
      Delete the rows where `col = value`.
  enum : String -> List ( v, String ) -> Table a -> Table a
      Map a nullary-enum column to/from a stored TEXT name, as (value, name)
  findBy : Db -> Table a -> String -> p -> Task Error (Maybe a)
      The single row where `col = value`, or Nothing.
  index : String -> Table a -> Table a
      Add a secondary index on a column.
  insert : Db -> Table a -> a -> Task Error Int
      Insert a record (all columns).
  primaryKey : String -> Table a -> Table a
      Mark the primary-key column.
  select : Db -> Table a -> String -> List p -> Task Error (List a)
      Rows matching a raw SQL tail (WHERE / ORDER BY / JOIN / LIMIT) + params.
  table : String -> a -> Table a
      Define a table from a record type. The second argument is a zero-value
  unique : String -> Table a -> Table a
      Add a UNIQUE constraint on a column.
  update : Db -> Table a -> String -> p -> a -> Task Error Int
      Update a record by its key column: `update conn t "id" p.id p`.