summaryrefslogtreecommitdiff
path: root/lib/value/value.mli
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-20 16:23:53 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-20 16:23:53 +0100
commitb05e2d2be7be28ee6c577671002797cf9abaf177 (patch)
tree0474684d619721024f0a6cb132cf2f4d2e84c344 /lib/value/value.mli
parentc4ca180fd7c2085e3ce3f8e32aa0c2cb724f4c53 (diff)
New module for working with Values
Diffstat (limited to 'lib/value/value.mli')
-rw-r--r--lib/value/value.mli46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/value/value.mli b/lib/value/value.mli
new file mode 100644
index 0000000..42482f7
--- /dev/null
+++ b/lib/value/value.mli
@@ -0,0 +1,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 *)