cake/adapter/postgres

🎂Cake 🐘PostgreSQL adapter which passes PreparedStatements to the pog library for execution.

Values

pub fn execute_raw_sql(
  sql_string sql_string: String,
  db_connection on: pog.Connection,
) -> Result(pog.Returned(Nil), pog.QueryError)
pub fn read_query_to_prepared_statement(
  query query: @internal ReadQuery,
) -> @internal PreparedStatement

Convert a Cake ReadQuery to a PreparedStatement.

pub fn run_query(
  query query: cake.CakeQuery(a),
  decoder decoder: decode.Decoder(a),
  db_connection db_connection: pog.Connection,
) -> Result(List(a), pog.QueryError)

Run a Cake CakeQuery against an PostgreSQL database.

This function is a wrapper around run_read_query and run_write_query.

pub fn run_read_query(
  query query: @internal ReadQuery,
  decoder decoder: decode.Decoder(a),
  db_connection on: pog.Connection,
) -> Result(List(a), pog.QueryError)
pub fn run_write_query(
  query query: @internal WriteQuery(a),
  decoder decoder: decode.Decoder(b),
  db_connection on: pog.Connection,
) -> Result(List(b), pog.QueryError)

Run a Cake WriteQuery against an PostgreSQL database.

pub fn with_connection(
  host host: String,
  port port: Int,
  username username: String,
  password password: option.Option(String),
  database database: String,
  callback callback: fn(pog.Connection) -> a,
) -> a

Runs a callbakc on a connection to a PostgreSQL database.

NOTICE: ⚠️⚠️⚠️ You should probably be using gleam_erlang’s supervisor.new, supervisor.add, and supervisor.start instead, to create the database connection.

See pog’s official documentation https://hexdocs.pm/pog/.

This is a thin wrapper around the pog library’s Connection type.

pub fn with_named_connection(
  process process: process.Name(pog.Message),
  host host: String,
  port port: Int,
  username username: String,
  password password: option.Option(String),
  database database: String,
  callback callback: fn(pog.Connection) -> a,
) -> a

Runs a callback on a connection to a PostgreSQL database.

NOTICE: ⚠️⚠️⚠️ You should probably be using gleam_erlang’s supervisor.new, supervisor.add, and supervisor.start instead, to create the database connection.

See pog’s official documentation https://hexdocs.pm/pog/.

This is a thin wrapper around the pog library’s Connection type.

In addition to with_connection you may specify the erlang process name.

pub fn write_query_to_prepared_statement(
  query query: @internal WriteQuery(a),
) -> @internal PreparedStatement

Convert a Cake WriteQuery to a PreparedStatement.

Search Document