Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Convenience module for couchDB

  • Loading branch information...
commit d282ea820abb756fa22abbb9832d889994eaff03 1 parent d747f8e
@VictorNicollet authored
Showing with 55 additions and 0 deletions.
  1. +4 −0 src/couchDB.ml
  2. +19 −0 src/couchDB.mli
  3. +32 −0 src/couchDB_convenience.ml
View
4 src/couchDB.ml
@@ -51,3 +51,7 @@ module DocView = ImplViews.DocView
module MapView = ImplViews.MapView
let compile_views () = ImplViews.compile_views ()
+
+(* Convenience module ---------------------------------------------------------------------- *)
+
+module Convenience = CouchDB_convenience
View
19 src/couchDB.mli
@@ -220,3 +220,22 @@ module ReduceView :
val compact : unit -> unit
val compile_views : unit -> unit
+
+module Convenience : sig
+
+ module type LOCAL_CONFIG = sig
+ val db : string
+ end
+
+ module Config : functor(Config:LOCAL_CONFIG) -> CONFIG
+ module Database : functor(Config:LOCAL_CONFIG) -> DATABASE
+ module Table :
+ functor (Config:LOCAL_CONFIG) ->
+ functor (Id:ID) ->
+ functor (Type:Fmt.FMT) ->
+ sig
+ module MyTable : TABLE with type id = Id.t and type elt = Type.t
+ module Design : DESIGN
+ end
+
+end
View
32 src/couchDB_convenience.ml
@@ -0,0 +1,32 @@
+(* Ohm is © 2012 Victor Nicollet *)
+
+module ImplTable = CouchDB_table
+module ImplTypes = CouchDB_types
+
+module type LOCAL_CONFIG = sig
+ val db : string
+end
+
+module Config = functor (C:LOCAL_CONFIG) -> struct
+ let host = "localhost"
+ let port = 5984
+ let database = C.db
+end
+
+module Database = functor(C:LOCAL_CONFIG) -> struct
+ module C = Config(C)
+ include ImplTable.Database(C)
+end
+
+module Table =
+ functor(C:LOCAL_CONFIG) ->
+ functor (Id:ImplTypes.ID) ->
+ functor (Type:Fmt.FMT) ->
+struct
+ module Db = Database(C)
+ module MyTable = ImplTable.Table(Db)(Id)(Type)
+ module Design = struct
+ module Database = Db
+ let name = C.db
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.