package caqti-async

  1. Overview
  2. Docs

Module CONNECTION.ResponseSource

Sourcetype ('b, +'m) t

The type describing the response and containing returned data from a request execution.

  • 'b is the type of a single row
  • 'm is the possible multiplicities of rows

Result inspection

Sourceval returned_count : ('b, 'm) t -> (int, [> Caqti_error.retrieve | `Unsupported ]) result Async_kernel.Deferred.t

returned_count resp is the number of rows returned by resp. This function may not be available for all drivers.

Sourceval affected_count : ('b, 'm) t -> (int, [> Caqti_error.retrieve | `Unsupported ]) result Async_kernel.Deferred.t

affected_count resp is the number of rows affected by the updated the produced resp. This function may not be available for all drivers.

Result retrieval

Sourceval exec : (unit, [< `Zero ]) t -> (unit, [> Caqti_error.retrieve ]) result Async_kernel.Deferred.t

exec resp checks that resp succeeded with no result rows.

Sourceval find : ('b, [< `One ]) t -> ('b, [> Caqti_error.retrieve ]) result Async_kernel.Deferred.t

find resp checks that resp succeeded with a single row, and returns the decoded row.

Sourceval find_opt : ('b, [< `Zero | `One ]) t -> ('b option, [> Caqti_error.retrieve ]) result Async_kernel.Deferred.t

find_opt resp checks that resp succeeded with at most one row, and returns the row if any.

Sourceval fold : ('b -> 'c -> 'c) -> ('b, 'm) t -> 'c -> ('c, [> Caqti_error.retrieve ]) result Async_kernel.Deferred.t

fold f resp folds f over the decoded rows returned in resp.

Sourceval fold_s : ('b -> 'c -> ('c, 'e) result Async_kernel.Deferred.t) -> ('b, 'm) t -> 'c -> ('c, [> Caqti_error.retrieve ] as 'e) result Async_kernel.Deferred.t

fold_s f resp folds f over the decoded rows returned by resp within the IO and result monad.

Note. Do not make nested queries in the callback to this function. If you use the same connection, it may lead to data corruption. If you pull a different connection from the same pool, it may deadlock if the pool runs out of connections. Also, some drivers may not support simpltaneous connections.

Sourceval iter_s : ('b -> (unit, 'e) result Async_kernel.Deferred.t) -> ('b, 'm) t -> (unit, [> Caqti_error.retrieve ] as 'e) result Async_kernel.Deferred.t

iter_s f resp iterates f over the decoded rows returned by resp within the IO and result monad.

Note. Do not make nested queries in the callback to this function. Cf. fold_s.

Sourceval to_stream : ('b, 'm) t -> ('b, [> Caqti_error.retrieve ] as 'err) Stream.t

to_stream resp returns a stream whose elements are the decoded rows returned by resp.

OCaml

Innovation. Community. Security.