summaryrefslogtreecommitdiff
path: root/lib/value/value.mli
blob: 42482f7aeca018384b697fcfbeacf95a750c0b78 (plain)
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
(** 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 Fields = Fields
(** The fields of a value, each with its associated data *)

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],
    [Data.seq]); 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 : ('a, Model.target) Model.Typ.t * 'a -> value
(** [single (typ, data)]: a single value for the field, together with the type
    [typ] of the field *)

val multi : (int64, Model.target) Model.Typ.t * int64 Seq.t -> value
(** [multi (typ, ids)]: a sequence of references for a multivalued 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
(** The primary key of the value in its table *)