package caqti

  1. Overview
  2. Docs

Query

module Response : Caqti_response_sig.S with type 'a future := 'a future
val call : f:(('b, 'm) Response.t -> ('c, 'e) result future) -> ('a, 'b, 'm) Caqti_request.t -> 'a -> ('c, [> Caqti_error.call ] as 'e) result future

call ~f request params performs request with parameters params invoking f to process the result. The argument of f is only valid during the call to f, and must not be returned or operated on by other threads.

Transactions

val start : unit -> (unit, [> Caqti_error.transact ]) result future

Starts a transaction if supported by the underlying database, otherwise does nothing.

val commit : unit -> (unit, [> Caqti_error.transact ]) result future

Commits the current transaction if supported by the underlying database, otherwise does nothing.

val rollback : unit -> (unit, [> Caqti_error.transact ]) result future

Rolls back a transaction if supported by the underlying database, otherwise does nothing.

Disconnection and Reuse

val disconnect : unit -> unit future

Calling disconnect () closes the connection to the database and frees up related resources.

val validate : unit -> bool future

For internal use by Caqti_pool. Tries to ensure the validity of the connection and must return false if unsuccessful.

val check : (bool -> unit) -> unit

For internal use by Caqti_pool. Called after a connection has been used. check f must call f () exactly once with an argument indicating whether to keep the connection in the pool or discard it.