Neodriver_eio.Neo4jResultA 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.
val make :
?fetch_size:int ->
?query:string ->
?parameters:(string * Neodriver_core.Values.t) list ->
Conn.stream ->
tWrap 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.streamThe underlying stream (for the summary, buffered records and raw pull).
val keys : t -> string listThe field names of the returned records.
val check_keys :
t ->
'a Neodriver_core.Decode.t ->
(unit, Neodriver_core.Errors.t) Stdlib.resultCheck that decoder can find every field it requires (its Decode.aliases) in the result's field names. Extra result fields are allowed; a missing required field or a duplicate result field name is an Errors.Decode_error. Fields read with Decode.field_opt or Decode.field_or are optional and are not required. RUN already reports the field names, so this can reject a wrong query/decoder pair before any record is pulled.
val next :
t ->
(Neodriver_core.Values.t list option, Neodriver_core.Errors.t) Stdlib.resultThe next record, or None once the stream is exhausted.
val next_as :
t ->
'a Neodriver_core.Decode.t ->
('a option, Neodriver_core.Errors.t) Stdlib.resultLike next, but decode the record with decoder. Field names come from the result's RUN metadata, so decoding is by name, not by position. The record is consumed even when decoding fails; the rest of the stream stays readable (drain it with consume). The server-failure/consumed-result behaviour is exactly that of next.
val peek :
t ->
(Neodriver_core.Values.t list option, Neodriver_core.Errors.t) Stdlib.resultThe next record without advancing past it.
val fetch :
?n:int ->
t ->
(Neodriver_core.Values.t list list, Neodriver_core.Errors.t) Stdlib.resultUp to n records (all remaining when n is omitted).
val values :
t ->
(Neodriver_core.Values.t list list, Neodriver_core.Errors.t) Stdlib.resultAll remaining records.
val list :
t ->
(Neodriver_core.Values.t list list, Neodriver_core.Errors.t) Stdlib.resultAll 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.resultAll remaining records, each paired with its field names. A record whose number of values does not match the number of field names is a Errors.Broken_record_error.
val decode_all :
t ->
'a Neodriver_core.Decode.t ->
('a list, Neodriver_core.Errors.t) Stdlib.resultAll remaining records, decoded with decoder. On a decode failure the rest of the stream is discarded and the error names the 1-based record number.
val consume : t -> (Summary.t, Neodriver_core.Errors.t) Stdlib.resultDrain the stream and return its summary.
val single :
t ->
(Neodriver_core.Values.t list, Neodriver_core.Errors.t) Stdlib.resultThe single remaining record; an error unless exactly one.
val decode_single :
t ->
'a Neodriver_core.Decode.t ->
('a, Neodriver_core.Errors.t) Stdlib.resultLike single, decoded with decoder.
val single_optional :
t ->
(Neodriver_core.Values.t list option * string list, Neodriver_core.Errors.t)
Stdlib.resultExpect 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).
val decode_single_optional :
t ->
'a Neodriver_core.Decode.t ->
('a option * string list, Neodriver_core.Errors.t) Stdlib.resultLike single_optional, with the record decoded by decoder.