Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
module Database : sig ... end
Sanddb.Database
contains the type of the database and it's internal implementation.
module Record_id : sig ... end
Sanddb.Record_id
is the basic record id type, which idetifies a record in the database. It's compatible with base's Set type.
module Serializer : sig ... end
Sanddb.Serializer
contains the different kind of serializers that are possible with SandDB.
val create_json_database :
Lwt_io.file_name ->
(module Serializer.Json_serializer with type t = 'a) ->
(module Database.T
with type t = 'a)
Sanddb.create_json_database file_name json_serializer
will create a json database based on the provided:
file_name
which will be tha base of the databasejson_serializer
which will be responsible for the serialization between the database and the client This function will return a first class database module, which can be used to communicate with the database.val create_biniou_database :
Lwt_io.file_name ->
(module Serializer.Biniou_serializer with type t = 'a) ->
(module Database.T
with type t = 'a)
Sanddb.create_biniou_database file_name biniou_serializer
will create a biniou database based on the provided:
file_name
which will be tha base of the databasebiniou_serializer
which will be responsible for the serialization between the database and the client This function will return a first class database module, which can be used to communicate with the database.val read_all_records :
(module Database.T with type t = 'a) ->
unit ->
(Record_id.t * 'a, exn) Stdlib.result list Lwt.t
Sanddb.read_all_records database unit
gives back every database record, both visible and shadowed ones. The result can contain duplicate record ids. The first record in the list is the oldest record and the last one is the newest record. Creates the database file if it doesn't exists.
val read_visible_records :
(module Database.T with type t = 'a) ->
unit ->
(Record_id.t * 'a, exn) Stdlib.result list Lwt.t
Sanddb.read_visible_records database unit
gives back every visible(not shadowed) database record, which also means there is no duplicate record id in the result. The first record in the list is the newest record and the last one is the oldest record. Creates the database file if it doesn't exists.
val insert_record :
(module Database.T with type t = 'a) ->
'a ->
Record_id.t Lwt.t
Sanddb.insert_record database data
inserts record into the database. The record id is generated automatically and given back as a result. Creates the database file if it doesn't exists.
val insert_shadowing_record :
(module Database.T with type t = 'a) ->
Record_id.t ->
'a ->
Record_id.t Lwt.t
Sanddb.insert_record database data
inserts record into the database with the given record id. It can shadow an older record if it has the same record id as the new one. Creates the database file if it doesn't exists.