Module Petrol.Request

This module defines a request type t that can be executed by Caqti (see exec, find, find_opt). The functions defined in this module cache their inputs, so it is safe to call these repeatedly.

Note In order to cache a query, Petrol uses the string representation of the query with holes for variables as the cache key -- this means that you are highly recommended to not use the static constant functions for any values that change frequently and instead use the non-static constant functions.

type ('res, 'multiplicity) t = ('res, 'multiplicity) request

Represents a compiled SQL database request.

val make_zero : (unit, 'b) query -> (unit, [ `Zero ]) t

make_zero query constructs a SQL request with multiplicity zero from the query query.

val make_one : ('a, 'b) query -> ('a, [ `One ]) t

make_one query constructs a SQL request with multiplicity one from the query query.

val make_zero_or_one : ('a, 'b) query -> ('a, [ `One | `Zero ]) t

make_one query constructs a SQL request with multiplicity zero or one from the query query.

val make_many : ('a, 'b) query -> ('a, [ `Many | `One | `Zero ]) t

make_one query constructs a SQL request with multiplicity zero or more from the query query.