based/pg
Types
pub type Config =
pgl.Config
pub opaque type Connection
Values
pub fn application(
config: pgl.Config,
application: String,
) -> pgl.Config
Name of the application connecting to the database.
pub fn begin(
conn: Connection,
) -> Result(Connection, based.TransactionError(err))
Manually begins a transaction on the given connection.
pub fn commit(
conn: Connection,
) -> Result(Connection, based.TransactionError(err))
Commits the current transaction on the given connection.
pub const config: pgl.Config
pub fn connection_parameter(
config: pgl.Config,
name name: String,
value value: String,
) -> pgl.Config
Sets other postgres connection parameters.
pub fn database(
config: pgl.Config,
database: String,
) -> pgl.Config
The name of the database to use.
pub fn db(db: Db) -> based.Db(pg_value.Value, Connection)
Returns a based.Db that can be used with based.query, based.execute,
based.all, and other based functions.
pub fn from_url(url: String) -> Result(pgl.Config, Nil)
Build a Config from a PostgreSQL connection URL.
Supports postgres:// and postgresql:// schemes.
Returns Error(Nil) if the URL is invalid or uses an unsupported scheme.
pub fn idle_interval(
config: pgl.Config,
idle_interval: Int,
) -> pgl.Config
How often idle connections should ping the database server.
pub fn ip_version(
config: pgl.Config,
ip_version: IpVersion,
) -> pgl.Config
Which IP version to use
pub fn new(config: pgl.Config) -> Db
Creates a new database instance from a config. Call start to open
the connection pool before using it.
pub fn password(
config: pgl.Config,
password: String,
) -> pgl.Config
The password of the user.
pub fn pool_size(
config: pgl.Config,
pool_size: Int,
) -> pgl.Config
Sets the size of the connection pool.
pub fn port(config: pgl.Config, port: Int) -> pgl.Config
The port on which the database server is listening.
pub fn queue_target(
config: pgl.Config,
queue_target: Int,
) -> pgl.Config
How long it should take to check out a connection from the connection pool.
pub fn rollback(
conn: Connection,
) -> Result(Connection, based.TransactionError(err))
Rolls back the current transaction on the given connection.
pub fn rows_as_dict(
config: pgl.Config,
rows_as_dict: Bool,
) -> pgl.Config
Configures rows to be returned as Dict rather than n-tuples.
pub fn start(
db: Db,
) -> Result(
actor.Started(static_supervisor.Supervisor),
actor.StartError,
)
Starts the connection pool for the given database under a new supervisor.
pub fn supervised(
db: Db,
) -> supervision.ChildSpecification(static_supervisor.Supervisor)
Returns a child specification for starting the connection pool under an existing supervision tree.
pub fn transaction(
conn: Connection,
next: fn(Connection) -> Result(t, err),
) -> Result(t, based.TransactionError(err))
Executes a function within a database transaction. If next returns
Ok, the transaction is committed. If it returns Error or panics,
the transaction is rolled back.
pub fn username(
config: pgl.Config,
username: String,
) -> pgl.Config
The username to connect to the database as.