@@ -23,79 +23,92 @@ module type RPC = sig
2323 (* * [rpc request] transmits [request] and receives a response *)
2424end
2525
26+ type table = string
27+
28+ type field_name = string
29+
30+ type field = string
31+
32+ type db_ref = string
33+
34+ type uuid = string
35+
36+ type regular_fields = (field_name * field ) list
37+
38+ type associated_fields = (field_name * db_ref list ) list
39+
2640(* * dictionary of regular fields x dictionary of associated set_ref values *)
27- type db_record = ( string * string ) list * ( string * string list ) list
41+ type db_record = regular_fields * associated_fields
2842
2943(* * The client interface to the database *)
3044module type DB_ACCESS = sig
3145 val initialise : unit -> unit
3246 (* * [initialise ()] must be called before any other function in this
3347 interface *)
3448
35- val get_table_from_ref : Db_ref .t -> string -> string option
36- (* * [get_table_from_ref ref] returns [Some tbl] if [ref] is a
49+ val get_table_from_ref : Db_ref .t -> db_ref -> table option
50+ (* * [get_table_from_ref ref tbl ] returns [Some tbl] if [ref] is a
3751 valid reference; None otherwise *)
3852
39- val is_valid_ref : Db_ref .t -> string -> bool
53+ val is_valid_ref : Db_ref .t -> db_ref -> bool
4054 (* * [is_valid_ref ref] returns true if [ref] is valid; false otherwise *)
4155
42- val read_refs : Db_ref .t -> string -> string list
56+ val read_refs : Db_ref .t -> table -> db_ref list
4357 (* * [read_refs tbl] returns a list of all references in table [tbl] *)
4458
4559 val find_refs_with_filter :
46- Db_ref .t -> string -> Db_filter_types .expr -> string list
60+ Db_ref .t -> table -> Db_filter_types .expr -> db_ref list
4761 (* * [find_refs_with_filter tbl expr] returns a list of all references
4862 to rows which match [expr] *)
4963
50- val read_field_where : Db_ref .t -> Db_cache_types .where_record -> string list
64+ val read_field_where : Db_ref .t -> Db_cache_types .where_record -> field list
5165 (* * [read_field_where {tbl,return,where_field,where_value}] returns a
5266 list of the [return] fields in table [tbl] where the [where_field]
5367 equals [where_value] *)
5468
55- val db_get_by_uuid : Db_ref .t -> string -> string -> string
69+ val db_get_by_uuid : Db_ref .t -> table -> uuid -> db_ref
5670 (* * [db_get_by_uuid tbl uuid] returns the single object reference
5771 associated with [uuid] *)
5872
59- val db_get_by_uuid_opt : Db_ref .t -> string -> string -> string option
73+ val db_get_by_uuid_opt : Db_ref .t -> table -> uuid -> db_ref option
6074 (* * [db_get_by_uuid_opt tbl uuid] returns [Some obj] with the single object
6175 reference associated with [uuid] if one exists and [None] otherwise,
6276 instead of raising an exception like [get_by_uuid] *)
6377
64- val db_get_by_name_label : Db_ref .t -> string -> string -> string list
78+ val db_get_by_name_label : Db_ref .t -> table -> string -> db_ref list
6579 (* * [db_get_by_name_label tbl label] returns the list of object references
6680 associated with [label] *)
6781
68- val create_row :
69- Db_ref .t -> string -> (string * string ) list -> string -> unit
82+ val create_row : Db_ref .t -> table -> regular_fields -> db_ref -> unit
7083 (* * [create_row tbl kvpairs ref] create a new row in [tbl] with
7184 key [ref] and contents [kvpairs] *)
7285
73- val delete_row : Db_ref .t -> string -> string -> unit
86+ val delete_row : Db_ref .t -> db_ref -> table -> unit
7487 (* * [delete_row context tbl ref] deletes row [ref] from table [tbl] *)
7588
76- val write_field : Db_ref .t -> string -> string -> string -> string -> unit
89+ val write_field : Db_ref .t -> table -> db_ref -> field_name -> field -> unit
7790 (* * [write_field context tbl ref fld val] changes field [fld] to [val] in
7891 row [ref] in table [tbl] *)
7992
80- val read_field : Db_ref .t -> string -> string -> string -> string
81- (* * [read_field context tbl ref fld] returns the value of field [fld]
93+ val read_field : Db_ref .t -> table -> field_name -> db_ref -> field
94+ (* * [read_field context tbl fld ref ] returns the value of field [fld]
8295 in row [ref] in table [tbl] *)
8396
84- val read_record : Db_ref .t -> string -> string -> db_record
97+ val read_record : Db_ref .t -> table -> db_ref -> db_record
8598 (* * [read_record tbl ref] returns
8699 [ (field, value) ] * [ (set_ref fieldname * [ ref ]) ] *)
87100
88101 val read_records_where :
89- Db_ref .t -> string -> Db_filter_types .expr -> (string * db_record ) list
102+ Db_ref .t -> table -> Db_filter_types .expr -> (db_ref * db_record ) list
90103 (* * [read_records_where tbl expr] returns a list of the values returned
91104 by read_record that match the expression *)
92105
93106 val process_structured_field :
94107 Db_ref .t
95- -> string * string
96- -> string
97- -> string
98- -> string
108+ -> field_name * field
109+ -> table
110+ -> field_name
111+ -> db_ref
99112 -> Db_cache_types .structured_op_t
100113 -> unit
101114 (* * [process_structured_field context kv tbl fld ref op] modifies the
0 commit comments