summaryrefslogtreecommitdiff
path: root/lib/query/query.mli
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-21 11:23:41 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-21 11:23:41 +0100
commitce13c93cf14cb71894481b0303a7058a72a6f4ce (patch)
treebd93186a65f6645cb4401f188d266d743cc2fde7 /lib/query/query.mli
parent172a02b80d8dbdcfe09129d7fa76015bb5ec4d79 (diff)
Load values from the database
Diffstat (limited to 'lib/query/query.mli')
-rw-r--r--lib/query/query.mli35
1 files changed, 21 insertions, 14 deletions
diff --git a/lib/query/query.mli b/lib/query/query.mli
index cd7287f..ae7245e 100644
--- a/lib/query/query.mli
+++ b/lib/query/query.mli
@@ -1,17 +1,16 @@
val insert :
Caqti_lwt.connection ->
Model.content ->
- ?parent:Model.content Value.t ->
- (string -> Value.value) ->
- Model.content Value.t Lwt.t
-(** Insert a new element and return it as a value.
+ ?parent:Int64.t ->
+ (string -> Model.target Model.Data.any) ->
+ int64 Lwt.t
+(** Insert a new element in the database and return the id of the new row.
- [insert db content ~parent provider] will create the content in the database
- and return the inserted row as a [Value.t] (the content together with its
- new id).
+ [insert db content ~parent provider] creates the content in the database and
+ returns the primary key of the inserted row.
- The parent — itself a value — is required if the content is a subcontent.
- Not providing the parameter will raise the error [TypeMismatch].
+ The [parent] — the id of the parent row — is required if the content is a
+ subcontent. Not providing the parameter will raise the error [TypeMismatch].
For each field in the content, the function [provider] will be called with
the name for this property. The value returned shall match the expected type
@@ -23,10 +22,9 @@ val insert :
val insert_list :
Caqti_lwt.connection ->
Model.list ->
- (string -> Value.value) ->
- Model.list Value.t Lwt.t
-(** Insert a row in the dedicated table of a static list, and return it as a
- value.
+ (string -> Model.target Model.Data.any) ->
+ int64 Lwt.t
+(** Insert a row in the dedicated table of a static list, and return its id.
The [provider] is called with the name of each field of the list, like
[insert]. This is the function used to populate the lists from their source.
@@ -38,5 +36,14 @@ val update :
Caqti_lwt.connection ->
Int64.t ->
Model.content ->
- (string -> Value.value) ->
+ (string -> Model.target Model.Data.any) ->
unit Lwt.t
+
+val select :
+ Caqti_lwt.connection ->
+ Int64.t ->
+ Model.content ->
+ Select.callback ->
+ unit Lwt.t
+(** Read a row of a content table and call the callback once per field with the
+ field's named type and its value. See [Query.Select.select] *)