From 056fcabaeec238a7aa927df39a90acea028b1aa0 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sun, 22 Nov 2026 13:58:16 +0100 Subject: Added an option for loading a value content without the multivaluated fields (allow single query) --- lib/query/select.mli | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'lib/query/select.mli') diff --git a/lib/query/select.mli b/lib/query/select.mli index 68e4d00..fb7787e 100644 --- a/lib/query/select.mli +++ b/lib/query/select.mli @@ -3,21 +3,27 @@ type callback = { f : 'db 'ocaml. - ('db, 'ocaml, Model.target) Model.Types.t Model.Types.named * 'ocaml -> unit; + (Model.Identifier.t * ('db, 'ocaml, Model.target) Model.Types.t) * 'ocaml -> + unit; } -(** A callback called once per field of the selected row, with the field's named - type and its data in the code representation ['ocaml] — a pair that can be - stored in a value's dictionary and read back as typed data. +(** A callback called once per field of the selected row, with the field's name + and type, and its data in the code representation ['ocaml] — a triple that + can be stored in a value's dictionary and read back as typed data. The field is existentially typed: ['db] and ['ocaml] are universally quantified in the record field, so a plain function works for a field of any - type: [ { f = fun (named, data) -> ... } ]. *) + type: [ { f = fun ((name, typ), data) -> ... } ]. *) val select : - Caqti_lwt.connection -> Int64.t -> Model.content -> callback -> unit Lwt.t -(** [select db id content callback] reads the row [id] in the table of [content] - and calls [callback.f] once per field of the content, with the field's named - type and its value: + Caqti_lwt.connection -> + ?multivalued:bool -> + Int64.t -> + Model.content -> + callback -> + unit Lwt.t +(** [select ?multivalued db id content callback] reads the row [id] in the table + of [content] and calls [callback.f] once per field of the content, with the + field's name and type, and its value: - the single-column fields ([Text], [Integer], [MonoReference], plus the reserved [parent] column of a subcontent) are read from the content table @@ -25,12 +31,22 @@ val select : - each multivalued reference field is read from its dedicated table ([content.field]) and yields the sequence of its targets ([int64 Seq.t]). + [~multivalued] (default [true]) controls whether those multivalued reference + fields are also read: with [~multivalued:false], only the row of the content + table is read and the callback is not called for them. + The [id] of the row itself is not passed to the callback: it is the [id] - argument. In the callback, each [(named, data)] pair can be stored in a - value's dictionary to make the field readable as typed data. *) + argument. In the callback, each [((name, typ), data)] triple can be stored + in a value's dictionary to make the field readable as typed data. *) val select_list : - Caqti_lwt.connection -> Int64.t -> Model.list -> callback -> unit Lwt.t + Caqti_lwt.connection -> + ?multivalued:bool -> + Int64.t -> + Model.list -> + callback -> + unit Lwt.t (** Same as {!select}, for a row of the dedicated table of a static list. Lists have no [parent] column; their multivalued reference fields are read from - their dedicated tables ([list.field]), like for contents. *) + their dedicated tables ([list.field]), like for contents, unless + [~multivalued:false] is given. *) -- cgit v1.2.3