Neodriver_core.DecodeTyped decoding of query results (name-based field lookup, one decoder for rows and node properties).
Typed decoding of query results.
A decoder turns the values of a record (or of a graph value) into an OCaml value. Field lookup is by name, using the field names the server reported for the result, so a decoder does not depend on column order.
A decoder that reads record fields also reads the properties of a Values.Node, Values.Relationship or Values.Unbound_relationship when it is applied to such a value. The same decoder therefore works for RETURN p, RETURN properties(p) and a plain row of RETURN p.name AS name, ...:
let person : person t =
let open Decode in
let+ name = field "name" string
and+ age = field "age" int in
{ name; age }field reports a missing key as an error; option only accepts Null, while field_opt accepts both a missing key and Null.
The environment a decoder runs against: a record's named values, or a single value whose properties are read when the value is a Map, Node or relationship.
A decoder producing an 'a from an env.
Run a decoder against a record: a list of (field_name, value) pairs, as produced by Neo4jResult.data or by zipping Neo4jResult.keys with a record.
Run a decoder against a single value. A Map uses its entries; a Node, Relationship or Unbound_relationship uses its properties.
val aliases : 'a t -> string listThe record field names the decoder requires from its current environment. field contributes only its own key (the nested decoder runs in a different environment); map propagates and both unions. field_opt and field_or tolerate a missing field and contribute nothing, so Neo4jResult.check_keys does not require them.
val row_of_values :
keys:string list ->
Values.t list ->
((string * Values.t) list, Errors.t) Stdlib.resultZip a positional record with the result's field names. A length mismatch is a Errors.Broken_record_error instead of an exception.
Check that the decoder can find every field it reads (its aliases) in keys. Extra keys are allowed; a missing field or a duplicate key is an Errors.Decode_error.
val string : string tval bool : bool tval int : int tA Values.Int that fits the OCaml int range; out-of-range values are an error.
val int64 : int64 tval float : float tval bytes : bytes tval uuid : string tA Values.Uuid in its canonical text form.
val date : Temporal.Date.t tval time : Temporal.Time.t tval datetime : Temporal.DateTime.t tval duration : Temporal.Duration.t tval point : Values.point tval vector : Values.vector tval node : Values.node tval relationship : Values.relationship tval unbound_relationship : Values.unbound_relationship tval path : Values.path tNull becomes None; any other value is decoded as Some. A missing field is still an error (use field_opt for that).
val succeed : 'a -> 'a tval fail : string -> 'a tA decoder that always fails with the given message (for application-level validation).
Read key and decode it. A missing key is an error listing the available fields.