Module Neodriver_eio.Neo4jResult

A lazily-streamed query result (next/peek/fetch/consume/single).

A lazily-streamed query result. next/peek/fetch iterate the records (pulling from the connection on demand); consume drains the stream and returns its summary; single/single_optional enforce cardinality.

A deferred server failure is surfaced as Error once the buffered records before it have been consumed.

type t

A lazily-streamed result over a connection.

val make : ?fetch_size:int -> ?query:string -> ?parameters:(string * Neodriver_core.Values.t) list -> Conn.stream -> t

Wrap a stream (as produced by Session.run or Tx.run) into a t. fetch_size is the number of records pulled per PULL when the buffer runs out (default 1000).

val stream : t -> Conn.stream

The underlying stream (for the summary, buffered records and raw pull).

val keys : t -> string list

The field names of the returned records.

val next : t -> (Neodriver_core.Values.t list option, Neodriver_core.Errors.t) Stdlib.result

The next record, or None once the stream is exhausted.

val peek : t -> (Neodriver_core.Values.t list option, Neodriver_core.Errors.t) Stdlib.result

The next record without advancing past it.

val fetch : ?n:int -> t -> (Neodriver_core.Values.t list list, Neodriver_core.Errors.t) Stdlib.result

Up to n records (all remaining when n is omitted).

val values : t -> (Neodriver_core.Values.t list list, Neodriver_core.Errors.t) Stdlib.result

All remaining records.

val list : t -> (Neodriver_core.Values.t list list, Neodriver_core.Errors.t) Stdlib.result

All remaining records, fetched in a single PULL (n = -1) — the TestKit Optimization:ResultListFetchAll behaviour of the idiomatic list(): any already-buffered records are consumed first and the rest pulled at once, instead of batch by batch with the configured fetch size.

val data : t -> ((string * Neodriver_core.Values.t) list list, Neodriver_core.Errors.t) Stdlib.result

All remaining records, each paired with its field names.

val consume : t -> (Summary.t, Neodriver_core.Errors.t) Stdlib.result

Drain the stream and return its summary.

val single : t -> (Neodriver_core.Values.t list, Neodriver_core.Errors.t) Stdlib.result

The single remaining record; an error unless exactly one.

val single_optional : t -> (Neodriver_core.Values.t list option * string list, Neodriver_core.Errors.t) Stdlib.result

Expect at most one record. Zero records is Ok (None, []); one is Ok (Some _, []); more than one returns the first record together with a warning (draining the rest of the stream).