packages feed

mongoDB 2.0.4 → 2.0.5

raw patch · 6 files changed

+33/−21 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Database.MongoDB.Query: MongoContext :: Pipe -> AccessMode -> Database -> MongoContext
+ Database.MongoDB.Query: mongoAccessMode :: MongoContext -> AccessMode
+ Database.MongoDB.Query: mongoDatabase :: MongoContext -> Database
+ Database.MongoDB.Query: mongoPipe :: MongoContext -> Pipe

Files

Database/MongoDB/Admin.hs view
@@ -1,6 +1,6 @@ -- | Database administrative functions -{-# LANGUAGE FlexibleContexts, OverloadedStrings, RecordWildCards #-}+{-# LANGUAGE CPP, FlexibleContexts, OverloadedStrings, RecordWildCards #-}  module Database.MongoDB.Admin (     -- * Admin@@ -28,7 +28,9 @@ ) where  import Prelude hiding (lookup)+#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif import Control.Concurrent (forkIO, threadDelay) import Control.Monad (forever, unless, liftM) import Data.IORef (IORef, newIORef, readIORef, writeIORef)
Database/MongoDB/Connection.hs view
@@ -18,7 +18,11 @@ import Prelude hiding (lookup) import Data.IORef (IORef, newIORef, readIORef) import Data.List (intersect, partition, (\\), delete)++#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif+ import Control.Monad (forM_) import Network (HostName, PortID(..), connectTo) import System.IO.Unsafe (unsafePerformIO)
Database/MongoDB/Internal/Protocol.hs view
@@ -5,7 +5,7 @@ -- "Database.MongoDB.Query" and "Database.MongoDB.Connection" instead.  {-# LANGUAGE RecordWildCards, StandaloneDeriving, OverloadedStrings #-}-{-# LANGUAGE FlexibleContexts, TupleSections, TypeSynonymInstances #-}+{-# LANGUAGE CPP, FlexibleContexts, TupleSections, TypeSynonymInstances #-} {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-}  module Database.MongoDB.Internal.Protocol (@@ -22,7 +22,9 @@     Username, Password, Nonce, pwHash, pwKey ) where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif import Control.Arrow ((***)) import Control.Monad (forM_, replicateM, unless) import Data.Binary.Get (Get, runGet)
Database/MongoDB/Internal/Util.hs view
@@ -7,7 +7,9 @@  module Database.MongoDB.Internal.Util where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif import Control.Exception (handle, throwIO, Exception) import Control.Monad (liftM, liftM2) import Data.Bits (Bits, (.|.))
Database/MongoDB/Query.hs view
@@ -7,7 +7,7 @@     Action, access, Failure(..), ErrorCode,     AccessMode(..), GetLastError, master, slaveOk, accessMode,     liftDB,-    MongoContext, HasMongoContext(..),+    MongoContext(..), HasMongoContext(..),     -- * Database     Database, allDatabases, useDb, thisDatabase,     -- ** Authentication@@ -51,7 +51,9 @@ import Data.Int (Int32) import Data.Maybe (listToMaybe, catMaybes) import Data.Word (Word32)+#if !MIN_VERSION_base(4,8,0) import Data.Monoid (mappend)+#endif import Data.Typeable (Typeable)  #if MIN_VERSION_base(4,6,0)@@ -95,7 +97,7 @@  access :: (MonadIO m) => Pipe -> AccessMode -> Database -> Action m a -> m a -- ^ Run action against database on server at other end of pipe. Use access mode for any reads and writes. Return Left on connection failure or read/write failure.-access myPipe myAccessMode myDatabase action = runReaderT action MongoContext{..}+access mongoPipe mongoAccessMode mongoDatabase action = runReaderT action MongoContext{..}  -- | A connection failure, or a read or write exception like cursor expired or inserting a duplicate key. -- Note, unexpected data from the server is not a Failure, rather it is a programming error (you should call 'error' in this case) because the client and server are incompatible and requires a programming change.@@ -135,7 +137,7 @@  accessMode :: (Monad m) => AccessMode -> Action m a -> Action m a -- ^ Run action with given 'AccessMode'-accessMode mode act = local (\ctx -> ctx {myAccessMode = mode}) act+accessMode mode act = local (\ctx -> ctx {mongoAccessMode = mode}) act  readMode :: AccessMode -> ReadMode readMode ReadStaleOk = StaleOk@@ -148,26 +150,26 @@  -- | Values needed when executing a db operation data MongoContext = MongoContext {-    myPipe :: Pipe, -- ^ operations read/write to this pipelined TCP connection to a MongoDB server-    myAccessMode :: AccessMode, -- ^ read/write operation will use this access mode-    myDatabase :: Database } -- ^ operations query/update this database+    mongoPipe :: Pipe, -- ^ operations read/write to this pipelined TCP connection to a MongoDB server+    mongoAccessMode :: AccessMode, -- ^ read/write operation will use this access mode+    mongoDatabase :: Database } -- ^ operations query/update this database -myReadMode :: MongoContext -> ReadMode-myReadMode = readMode . myAccessMode+mongoReadMode :: MongoContext -> ReadMode+mongoReadMode = readMode . mongoAccessMode -myWriteMode :: MongoContext -> WriteMode-myWriteMode = writeMode . myAccessMode+mongoWriteMode :: MongoContext -> WriteMode+mongoWriteMode = writeMode . mongoAccessMode  send :: (MonadIO m) => [Notice] -> Action m () -- ^ Send notices as a contiguous batch to server with no reply. Throw 'ConnectionFailure' if pipe fails. send ns = do-    pipe <- asks myPipe+    pipe <- asks mongoPipe     liftIOE ConnectionFailure $ P.send pipe ns  call :: (MonadIO m) => [Notice] -> Request -> Action m (IO Reply) -- ^ Send notices and request as a contiguous batch to server and return reply promise, which will block when invoked until reply arrives. This call will throw 'ConnectionFailure' if pipe fails on send, and promise will throw 'ConnectionFailure' if pipe fails on receive. call ns r = do-    pipe <- asks myPipe+    pipe <- asks mongoPipe     promise <- liftIOE ConnectionFailure $ P.call pipe ns r     return (liftIOE ConnectionFailure promise) @@ -193,11 +195,11 @@  thisDatabase :: (Monad m) => Action m Database -- ^ Current database in use-thisDatabase = asks myDatabase+thisDatabase = asks mongoDatabase  useDb :: (Monad m) => Database -> Action m a -> Action m a -- ^ Run action against given database-useDb db act = local (\ctx -> ctx {myDatabase = db}) act+useDb db act = local (\ctx -> ctx {mongoDatabase = db}) act  -- * Authentication @@ -235,8 +237,8 @@ whereJS sel js = ("$where" =: js) : sel  class Select aQueryOrSelection where-	select :: Selector -> Collection -> aQueryOrSelection-	-- ^ 'Query' or 'Selection' that selects documents in collection that match selector. The choice of type depends on use, for example, in @'find' (select sel col)@ it is a Query, and in @'delete' (select sel col)@ it is a Selection.+    select :: Selector -> Collection -> aQueryOrSelection+    -- ^ 'Query' or 'Selection' that selects documents in collection that match selector. The choice of type depends on use, for example, in @'find' (select sel col)@ it is a Query, and in @'delete' (select sel col)@ it is a Selection.  instance Select Selection where     select = Select@@ -253,7 +255,7 @@  write :: (MonadIO m) => Notice -> Action m () -- ^ Send write to server, and if write-mode is 'Safe' then include getLastError request and raise 'WriteFailure' if it reports an error.-write notice = asks myWriteMode >>= \mode -> case mode of+write notice = asks mongoWriteMode >>= \mode -> case mode of     NoConfirm -> send [notice]     Confirm params -> do         let q = query (("getlasterror" =: (1 :: Int)) : params) "$cmd"@@ -507,7 +509,7 @@ -- ^ Translate Query to Protocol.Query. If first arg is true then add special $explain attribute. queryRequest isExplain Query{..} = do     ctx <- ask-    return $ queryRequest' (myReadMode ctx) (myDatabase ctx)+    return $ queryRequest' (mongoReadMode ctx) (mongoDatabase ctx)  where     queryRequest' rm db = (P.Query{..}, remainingLimit) where         qOptions = readModeOption rm ++ options
mongoDB.cabal view
@@ -1,5 +1,5 @@ Name:           mongoDB-Version:        2.0.4+Version:        2.0.5 Synopsis:       Driver (client) for MongoDB, a free, scalable, fast, document                 DBMS Description:    This package lets you connect to MongoDB servers and