Module Os.DbSource

This module defines low level functions for database requests.

include module type of Core_db
Sourcemodule PGOCaml : PGOCaml_generic.PGOCAML_GENERIC with type 'a monad = 'a Lwt.t
Sourceval init : ?host:string -> ?port:int -> ?user:string -> ?password:string -> ?database:string -> ?unix_domain_socket_dir:string -> ?pool_size:int -> ?init:(PGOCaml.pa_pg_data PGOCaml.t -> unit Lwt.t) -> unit -> unit

init ?host ?port ?user ?password ?database ?unix_domain_socket_dir ?init () initializes the variables for the database access and register a function init invoked each time a connection is created.

Sourceval full_transaction_block : (PGOCaml.pa_pg_data PGOCaml.t -> 'a Lwt.t) -> 'a Lwt.t

full_transaction_block f executes function f within a database transaction. The argument of f is a PGOCaml database handle.

Sourceval without_transaction : (PGOCaml.pa_pg_data PGOCaml.t -> 'a Lwt.t) -> 'a Lwt.t

without_transaction f executes function f outside a database transaction. The argument of f is a PGOCaml database handle.

Direct access to the connection pool

Sourcetype wrapper = {
  1. f : 'a. PGOCaml.pa_pg_data PGOCaml.t -> (unit -> 'a Lwt.t) -> 'a Lwt.t;
}

Setup a wrapper function which is used each time a connection is acquired. This function can perform some actions before and/or after the connection is used.

Sourceval set_connection_wrapper : wrapper -> unit
Sourceexception No_such_resource

Exception raised when no resource corresponds to the database request.

Sourceexception Wrong_password

Exception raised when password do not match.

Sourceexception Password_not_set

Exception raised when user has no password.

Sourceexception No_such_user

Exception raised when users attempts to connect with unknown identifier.

Sourceexception Empty_password

Exception raised when user attempts to connect with empty password.

Sourceexception Main_email_removal_attempt

Exception raised when there is an attempt to remove the main email.

Sourceexception Account_not_activated

Exception raised when the account is not activated.

Sourceval pwd_crypt_ref : ((string -> string) * (Types.User.id -> string -> string -> bool)) ref

pwd_crypt_ref is a reference to (f_crypt, f_check) where

  • f_crypt pwd is used to encrypt the password pwd.
  • f_check userid pwd hashed_pwd returns true if the hash of pwd and the hashed password hashed_pwd of the user with id userid match. If they don't match, it returns false.
Sourcemodule Email : sig ... end

This module is used for low-level email management with database.

Sourcemodule User : sig ... end

This module is used for low-level user management with database.

Sourcemodule Groups : sig ... end

This module is low-level and used to manage groups of user.

Sourcemodule Phone : sig ... end

Manage user phone numbers