Module Sqlite.Request

Module for creating SQL requests with metadata for tracing and debugging. This is a wrapper around Caqti's request system with additional metadata.

type ('a, 'b, +'m) t constraint 'm = [< `Zero | `One | `Many ]

Type of a SQL request with input type 'a, output type 'b, and multiplicity 'm. The multiplicity indicates how many rows the request is expected to return:

  • `Zero: No rows
  • `One: Exactly one row
  • `Many: Zero or more rows
val (->.) : 'a Caqti_type.t -> unit Caqti_type.t -> ?name:string -> ?table:string -> ?attrs:('a -> Opentelemetry.key_value list) -> ?oneshot:bool -> string -> ('a, unit, [ `Zero ]) t

a ->. unit creates a request that takes input of type a and returns no rows. Useful for INSERT, UPDATE, DELETE operations.

  • parameter name

    Optional name for the request for tracing

  • parameter table

    Optional table name this request operates on

  • parameter attrs

    Optional function to extract OpenTelemetry attributes from the input

  • parameter oneshot

    If true, the request will not be prepared

  • returns

    A request that expects no result rows

val (->!) : 'a Caqti_type.t -> 'b Caqti_type.t -> ?name:string -> ?table:string -> ?attrs:('a -> Opentelemetry.key_value list) -> ?oneshot:bool -> string -> ('a, 'b, [ `One ]) t

a ->! b creates a request that takes input of type a and returns exactly one row of type b. Useful for SELECT queries that must return exactly one result.

  • parameter name

    Optional name for the request for tracing

  • parameter table

    Optional table name this request operates on

  • parameter attrs

    Optional function to extract OpenTelemetry attributes from the input

  • parameter oneshot

    If true, the request will not be prepared

  • returns

    A request that expects exactly one result row

val (->?) : 'a Caqti_type.t -> 'b Caqti_type.t -> ?name:string -> ?table:string -> ?attrs:('a -> Opentelemetry.key_value list) -> ?oneshot:bool -> string -> ('a, 'b, [ `One | `Zero ]) t

a ->? b creates a request that takes input of type a and returns zero or one row of type b. Useful for SELECT queries that may not find a result.

  • parameter name

    Optional name for the request for tracing

  • parameter table

    Optional table name this request operates on

  • parameter attrs

    Optional function to extract OpenTelemetry attributes from the input

  • parameter oneshot

    If true, the request will not be prepared

  • returns

    A request that expects zero or one result row

val (->*) : 'a Caqti_type.t -> 'b Caqti_type.t -> ?name:string -> ?table:string -> ?attrs:('a -> Opentelemetry.key_value list) -> ?oneshot:bool -> string -> ('a, 'b, [ `Many | `One | `Zero ]) t

a ->* b creates a request that takes input of type a and returns any number of rows of type b. Useful for SELECT queries that return multiple results.

  • parameter name

    Optional name for the request for tracing

  • parameter table

    Optional table name this request operates on

  • parameter attrs

    Optional function to extract OpenTelemetry attributes from the input

  • parameter oneshot

    If true, the request will not be prepared

  • returns

    A request that can return any number of result rows