diff options
Diffstat (limited to 'lib/query/update.ml')
| -rw-r--r-- | lib/query/update.ml | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/query/update.ml b/lib/query/update.ml index 3c0941c..90db29d 100644 --- a/lib/query/update.ml +++ b/lib/query/update.ml @@ -1,6 +1,6 @@ (** Generate the update queries for a content *) -type provider = string -> Model.value +type provider = string -> Value.value module UpdateTemplate = Encoder.Map (struct type 'a t = string @@ -22,7 +22,7 @@ end) let update_fields : Caqti_lwt.connection -> Model.content -> - (Intf.t_type * (string * Model.value)) list -> + (Intf.t_type * (string * Value.value)) list -> int64 -> unit Lwt.t = fun db content fields id -> @@ -141,7 +141,7 @@ let update_mulivaluated_field : At this step, we can just use the code from the insert module. *) let remaining = ReferencesSet.(diff values (of_list remaining')) in - let v = Model.Typ.Seq (t, ReferencesSet.to_seq remaining) in + let v = Value.multi (t, ReferencesSet.to_seq remaining) in Insert.insert_references db content id field_name v data_type) Lwt.return_unit fields @@ -149,7 +149,7 @@ let q : Caqti_lwt.connection -> Int64.t -> Model.content -> - (string -> Model.value) -> + (string -> Value.value) -> unit Lwt.t = fun db id content provider -> let module Db = (val db) in @@ -170,11 +170,16 @@ let q : let tt = Intf.TT { name; content_type } in let value = provider (Model.Identifier.to_string name) in match value with - | Model.Typ.None -> acc - | Model.Typ.V _ as value -> - ( (tt, (Model.Identifier.to_string name, value)) :: fields, - references ) - | Model.Typ.Seq (t, seq) -> (fields, (name, t, seq) :: references)) + | Value.Data.Any d -> ( + match d with + | Value.Data.None -> acc + | Value.Data.V _ as dv -> + ( ( tt, + (Model.Identifier.to_string name, Value.Data.any dv) ) + :: fields, + references ) + | Value.Data.Seq (t, seq) -> + (fields, (name, t, seq) :: references))) ([], []) (Model.Content.fields content) in |
