From e8be496011c2a6cad885099f1b43967c212bb038 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Tue, 26 Jan 2010 02:40:00 -0500 Subject: [PATCH 1/3] A few comment spelling corrections --- Database/MongoDB.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Database/MongoDB.hs b/Database/MongoDB.hs index b69d24b..9ef6b78 100644 --- a/Database/MongoDB.hs +++ b/Database/MongoDB.hs @@ -41,7 +41,7 @@ module Database.MongoDB QueryOpt(..), UpdateFlag(..), count, countMatching, delete, insert, insertMany, query, remove, update, - -- * Convience collection operations + -- * Convenience collection operations find, findOne, quickFind, quickFind', -- * Cursor Cursor, @@ -79,11 +79,11 @@ import System.Random -- | A handle to a database connection data Connection = Connection { cHandle :: Handle, cRand :: IORef [Int] } --- | Estabilish a connection to a MongoDB server +-- | Establish a connection to a MongoDB server connect :: HostName -> IO Connection connect = flip connectOnPort $ Network.PortNumber 27017 --- | Estabilish a connection to a MongoDB server on a non-standard port +-- | Establish a connection to a MongoDB server on a non-standard port connectOnPort :: HostName -> Network.PortID -> IO Connection connectOnPort host port = do h <- Network.connectTo host port @@ -226,7 +226,7 @@ runCommand c db cmd = do fromBson (fromJust $ BSON.lookup "errmsg" res) return res --- | An Itertaor over the results of a query. Use 'nextDoc' to get each +-- | An Iterator over the results of a query. Use 'nextDoc' to get each -- successive result document, or 'allDocs' or 'allDocs'' to get lazy or -- strict lists of results. data Cursor = Cursor { @@ -534,7 +534,7 @@ getReply h = do -- | Return one document or Nothing if there are no more. --- Automatically closes the curosr when last document is read +-- Automatically closes the cursor when last document is read nextDoc :: Cursor -> IO (Maybe BsonDoc) nextDoc cur = do closed <- readIORef $ curClosed cur From 39eec9635735c9257c78819d69616fc4bc8a0fa7 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Tue, 26 Jan 2010 04:02:47 -0500 Subject: [PATCH 2/3] Add and expose serverShutdown. --- Database/MongoDB.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Database/MongoDB.hs b/Database/MongoDB.hs index 9ef6b78..f157d9a 100644 --- a/Database/MongoDB.hs +++ b/Database/MongoDB.hs @@ -28,7 +28,7 @@ module Database.MongoDB -- * Connection Connection, connect, connectOnPort, conClose, disconnect, dropDatabase, - serverInfo, + serverInfo, serverShutdown, databasesInfo, databaseNames, -- * Database Database, MongoDBCollectionInvalid, @@ -126,6 +126,14 @@ serverInfo :: Connection -> IO BsonDoc serverInfo c = runCommand c (s2L "admin") $ toBsonDoc [("buildinfo", toBson (1::Int))] +-- | Shut down the MongoDB server. +-- +-- Force a clean exit, flushing and closing all data files. +-- Note that it will wait until all ongoing operations are complete. +serverShutdown:: Connection -> IO BsonDoc +serverShutdown c = + runCommand c (s2L "admin") $ toBsonDoc [("shutdown", toBson (1::Int))] + -- | Return a list of collections in /Database/. collectionNames :: Connection -> Database -> IO [FullCollection] collectionNames c db = do From dc2f8aa03106160190df6717cfd9b772a594e28c Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Tue, 26 Jan 2010 04:03:59 -0500 Subject: [PATCH 3/3] Fix small white space error --- Database/MongoDB.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Database/MongoDB.hs b/Database/MongoDB.hs index f157d9a..0499791 100644 --- a/Database/MongoDB.hs +++ b/Database/MongoDB.hs @@ -130,7 +130,7 @@ serverInfo c = -- -- Force a clean exit, flushing and closing all data files. -- Note that it will wait until all ongoing operations are complete. -serverShutdown:: Connection -> IO BsonDoc +serverShutdown :: Connection -> IO BsonDoc serverShutdown c = runCommand c (s2L "admin") $ toBsonDoc [("shutdown", toBson (1::Int))]