Repodb.Stream
repodb · API reference
type config = {
batch_size : int;
max_rows : int option;
}Streaming and collection helpers for row-oriented query results.
The streaming facade wraps driver row iteration in folds and iterators. Use it for large result sets when building all rows in memory is unnecessary, or when a backend supports cursor-style fetching.
module Stream = Repodb.Stream.Make (Repodb_postgresql.Driver)
let count_active conn =
Stream.fold conn "SELECT id FROM users WHERE active = $1"
~params:[| Driver.Value.bool true |]
~init:0
~f:(fun count _row -> count + 1)cursor_fold and cursor_iter declare a cursor and fetch batches according to config. They are useful for PostgreSQL-style cursors; for drivers that materialize rows internally, they still provide a uniform API but do not reduce backend memory usage.
Sync and Seq provide small utility functions over already-materialized row lists or sequences. They are convenience helpers for tests and simple data processing; they do not perform database IO.
val default_config : configmodule type STREAM = sig ... endmodule Make
(D : Driver.S) :
STREAM with type connection = D.connection and type error = D.errormodule Sync : sig ... endmodule Seq : sig ... endval fold_raw :
query_fold:('a -> init:'b -> f:'c -> 'd) ->
sql:'a ->
init:'b ->
f:'c ->
'dval iter_raw : query_iter:('a -> f:'b -> 'c) -> sql:'a -> f:'b -> 'c