1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
(** Operations on the values stored in the database (fetching, updating, …).
A value is one row of a content or list table in the database. *)
module Data = Data
(** The data carried by a field: {!Data.data}, parameterized over the type of
the data held, built with the smart constructors ([Data.none], [Data.v]);
and {!Data.any}, the existential pack used when the held type is not known
statically *)
type value = Model.target Data.any
(** The data of a field of a content or a list, whatever the type of the data
held: an existential pack over {!Data.data} *)
val none : value
(** [none]: the field is empty (or left as is, on update) *)
val single : ('db, 'ocaml, Model.target) Model.Typ.t * 'ocaml -> value
(** [single (typ, data)]: the value for the field, in its code representation
['ocaml] — a single value, or an [int64 Seq.t] for a multivalued reference —
together with the type [typ] of the field *)
type 'a t
(** A value: a row of the table of the content or list ['a], identified by its
[id].
The parameter ['a] is the content or the static list whose table holds the
row: [Model.content] for contents ([Model.content Value.t]) and [Model.list]
for lists ([Model.list Value.t]).
The type is abstract: a value is built with [v] and inspected with [content]
and [id]. *)
val v : 'a -> int64 -> 'a t
(** Build a value from its content or list and its row id *)
val content : 'a t -> 'a
(** The content or list the value belongs to *)
val id : 'a t -> int64
[@@deprecated
"Use [Value.get v Value.id_ref] to read the primary key as typed data"]
(** The primary key of the value in its table *)
val id_ref : Model.target Model.Typ.monoreference Model.Typ.named
(** The pre-built {!Model.Typ.named} handle of the reserved field ["id"]
({!Model.Identifier.id}) — an integer field present in every row, content or
list. This is the key to read the primary key of any value. *)
val get :
'a t -> ('db, 'ocaml, Model.target) Model.Typ.t Model.Typ.named -> 'ocaml
(** Read a field of the value and return its data directly in its code
representation ['ocaml] — e.g. [get v id_ref : int64 option] is the primary
key of [v], and a multivalued reference field would yield an [int64 Seq.t].
The match between the requested named type and the readable field is proved
by {!Model.Typ.provably_equal} on name and type. Only the reserved field
[id_ref] is readable for now; the other fields are read from the database
(not implemented yet) and raise [Not_found]. *)
|