summaryrefslogtreecommitdiff
path: root/lib/query/query.mli
blob: cd7287f3c4593d6c590a8c84c20410dbf063a80c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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.

    [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).

    The parent — itself a value — 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
    for this property, the exception [TypeMismatch] is raised otherwise.

    This is a low-level function: there is no representation for the content
    itself, and no functionnals controls are realized. *)

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.

    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.
*)

val create : Caqti_lwt.connection -> Configuration.Ast.setting -> unit Lwt.t

val update :
  Caqti_lwt.connection ->
  Int64.t ->
  Model.content ->
  (string -> Value.value) ->
  unit Lwt.t