rethinkdb-client-driver 0.0.3 → 0.0.4
raw patch · 4 files changed
+32/−17 lines, 4 files
Files
- benchmark/Benchmark.hs +1/−1
- rethinkdb-client-driver.cabal +1/−1
- src/Database/RethinkDB.hs +1/−0
- src/Database/RethinkDB/Types.hs +29/−15
benchmark/Benchmark.hs view
@@ -38,6 +38,6 @@ h <- newHandle "localhost" defaultPort Nothing void $ run h (CreateTable db "benchmark")- void $ run h (InsertObject table (HMS.singleton "id" (String "id")))+ void $ run h (InsertObject CRError table (HMS.singleton "id" (String "id"))) return h
rethinkdb-client-driver.cabal view
@@ -1,5 +1,5 @@ name: rethinkdb-client-driver-version: 0.0.3+version: 0.0.4 license: MIT license-file: LICENSE author: Tomas Carnecky
src/Database/RethinkDB.hs view
@@ -18,6 +18,7 @@ , Sequence , Table, Database, SingleSelection , Res, Result, FromResponse+ , ConflictResolutionStrategy(..) , emptyOptions , lift , call1, call2
src/Database/RethinkDB/Types.hs view
@@ -223,11 +223,8 @@ instance IsSequence Table -instance Term Table where- toTerm = error "toTerm Table: Server-only type" - ------------------------------------------------------------------------------ -- | 'SingleSelection' is essentially a 'Maybe Object', where 'Nothing' is -- represented with 'Null' in the network protocol.@@ -235,9 +232,6 @@ data SingleSelection = SingleSelection deriving (Show) -instance Term SingleSelection where- toTerm = error "toTerm SingleSelection: Server-only type"- instance IsDatum SingleSelection instance IsObject SingleSelection @@ -249,11 +243,8 @@ data Database = MkDatabase -instance Term Database where- toTerm = error "toTerm Database: Server-only type" - ------------------------------------------------------------------------------ -- | Bounds are used in 'Between'. @@ -270,6 +261,31 @@ ------------------------------------------------------------------------------+-- | ConflictResolutionStrategy+--+-- How conflicts should be resolved.++data ConflictResolutionStrategy++ = CRError+ -- ^ Do not insert the new document and record the conflict as an error.+ -- This is the default.++ | CRReplace+ -- ^ Replace the old document in its entirety with the new one.++ | CRUpdate+ -- ^ Update fields of the old document with fields from the new one.+++instance ToDatum ConflictResolutionStrategy where+ toDatum CRError = String "error"+ toDatum CRReplace = String "replace"+ toDatum CRUpdate = String "update"++++------------------------------------------------------------------------------ -- | Used in 'OrderBy'. data Order = Ascending !Text | Descending !Text@@ -301,9 +317,6 @@ instance (FromDatum a) => FromResponse (Sequence a) where parseResponse = responseSequenceParser -instance Term (Sequence a) where- toTerm = error "toTerm Sequence: Server-only type"- instance IsSequence (Sequence a) instance (FromDatum a) => FromDatum (Sequence a) where@@ -390,7 +403,7 @@ IsEmpty :: (IsSequence a) => Exp a -> Exp Bool Delete :: Exp a -> Exp Object - InsertObject :: Exp Table -> Object -> Exp Object+ InsertObject :: ConflictResolutionStrategy -> Exp Table -> Object -> Exp Object -- Insert a single object into the table. InsertSequence :: (IsSequence s) => Exp Table -> Exp s -> Exp Object@@ -500,8 +513,9 @@ spec' <- mapM toTerm spec simpleTerm 41 ([s'] ++ spec') - toTerm (InsertObject table obj) =- termWithOptions 56 [SomeExp table, SomeExp (lift obj)] emptyOptions+ toTerm (InsertObject crs table obj) =+ termWithOptions 56 [SomeExp table, SomeExp (lift obj)] $+ HMS.singleton "conflict" (toDatum crs) toTerm (InsertSequence table s) = termWithOptions 56 [SomeExp table, SomeExp s] emptyOptions