diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-11-20 16:23:53 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-11-20 16:23:53 +0100 |
| commit | b05e2d2be7be28ee6c577671002797cf9abaf177 (patch) | |
| tree | 0474684d619721024f0a6cb132cf2f4d2e84c344 /lib/model | |
| parent | c4ca180fd7c2085e3ce3f8e32aa0c2cb724f4c53 (diff) | |
New module for working with Values
Diffstat (limited to 'lib/model')
| -rw-r--r-- | lib/model/model.ml | 1 | ||||
| -rw-r--r-- | lib/model/model.mli | 12 | ||||
| -rw-r--r-- | lib/model/typ.ml | 22 |
3 files changed, 5 insertions, 30 deletions
diff --git a/lib/model/model.ml b/lib/model/model.ml index bd8c010..2e58d0c 100644 --- a/lib/model/model.ml +++ b/lib/model/model.ml @@ -22,5 +22,4 @@ type section = target Section.t type field = target Field.t type field_ex = target Field.field_ex type reference = target Typ.reference -type value = target Typ.value type 'db typ = ('db, target) Typ.t diff --git a/lib/model/model.mli b/lib/model/model.mli index f51386c..6cf2b11 100644 --- a/lib/model/model.mli +++ b/lib/model/model.mli @@ -39,7 +39,8 @@ - {!Identifier} — the names of contents and fields, validated so that they are always safe to embed as SQL identifiers. - {!Content}, {!Section}, {!Field} — the structure of the model. - - {!Typ} — the field types, and the values carried by fields. + - {!Typ} — the field types (the nature of the data; the data itself lives + in the value package as [Value.value]). - {!Reference} — a link from a reference field to its target content. - {!DataList} — a static list declared in the configuration: referenceable, but not editable by the user. @@ -97,9 +98,9 @@ module Typ = Typ stored in a dedicated table ["content.field"]. A {!Typ.reference} record carries the target of a reference field (a - {!target}) plus optional [constraints] restricting the allowed values. A - {!Typ.value} is the data provided for a field when inserting/updating: - {!Typ.None} (leave as is), {!Typ.V} (a single value) or {!Typ.Seq} (a + {!target}) plus optional [constraints] restricting the allowed values. The + data provided for a field when inserting/updating is a [Value.value] (from + the value package): [None] (leave as is), [V] (a single value) or [Seq] (a sequence of references, for multivalued fields). *) type 'db typ = ('db, target) Typ.t @@ -136,9 +137,6 @@ module Section = Section type section = target Section.t (** A section of {!content} *) -type value = target Typ.value -(** A value provided for a field when inserting/updating data *) - module Field = Field (** A field of a content. diff --git a/lib/model/typ.ml b/lib/model/typ.ml index 6168c4c..173f08f 100644 --- a/lib/model/typ.ml +++ b/lib/model/typ.ml @@ -44,25 +44,3 @@ let eq : type a b c. (a, c) t -> (b, c) t -> (a, b) Type.eq option = | Text, Text -> Some Type.Equal | _ -> None -(** Represent the value in the database for a given field. - -Example for inserting data -[ - (* Function providing a value for each field to insert in the database *) - - let f : string -> Model.value = function - | "siret" -> V (Model.Typ.Text, Some "siret") - | "name" -> V (Model.Typ.Text, Some "name") - | _ -> None - - let* id = Query.insert db entity_content f in -] - -*) -type 't value = - | None (** None tell the field is empty in the database *) - | V : ('a option, 't) t * 'a option -> 't value - (** V is the value for the field. The field type is also reported in order - to give the compiler the nature of the data *) - | Seq : (int64, 't) t * int64 Seq.t -> 't value - (** Get a sequence of values for a multivaluated field *) |
