diff options
Diffstat (limited to 'lib/value/value.mli')
| -rw-r--r-- | lib/value/value.mli | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/lib/value/value.mli b/lib/value/value.mli index 42482f7..5c493aa 100644 --- a/lib/value/value.mli +++ b/lib/value/value.mli @@ -2,14 +2,11 @@ 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 *) + 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 @@ -18,12 +15,10 @@ type value = Model.target Data.any 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 *) +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 @@ -43,4 +38,22 @@ 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]. *) |
