From 847e8bac8b8b45c52abfe620fb07cea02ba39fe5 Mon Sep 17 00:00:00 2001 From: "Scott R. Parish" Date: Sat, 6 Feb 2010 14:56:56 -0600 Subject: [PATCH] create type aliases for Username and Password This will make the resulting documentation more clear what to pass to the login and addUser functions --- Database/MongoDB.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Database/MongoDB.hs b/Database/MongoDB.hs index 918e6b0..d749855 100644 --- a/Database/MongoDB.hs +++ b/Database/MongoDB.hs @@ -32,7 +32,7 @@ module Database.MongoDB serverInfo, serverShutdown, databasesInfo, databaseNames, -- * Database - Database, MongoDBCollectionInvalid, + Database, MongoDBCollectionInvalid, Password, Username, ColCreateOpt(..), collectionNames, createCollection, dropCollection, renameCollection, runCommand, validateCollection, @@ -399,6 +399,9 @@ type NumToSkip = Int32 -- and the way the cursor is being used. type NumToReturn = Int32 +type Username = String +type Password = String + -- | Options that control the behavior of a 'query' operation. data QueryOpt = QOTailableCursor | QOSlaveOK @@ -546,7 +549,7 @@ update c col flags sel obj = do return reqID -- | log into the mongodb /Database/ attached to the /Connection/ -login :: Connection -> Database -> String -> String -> IO BsonDoc +login :: Connection -> Database -> Username -> Password -> IO BsonDoc login c db user pass = do doc <- runCommand c db (toBsonDoc [("getnonce", toBson (1 :: Int))]) let nonce = fromBson $ fromLookup $ BSON.lookup "nonce" doc :: String @@ -559,7 +562,7 @@ login c db user pass = do in runCommand c db request -- | create a new user in the current /Database/ -addUser :: Connection -> Database -> String -> String -> IO BsonDoc +addUser :: Connection -> Database -> Username -> Password -> IO BsonDoc addUser c db user pass = do let userDoc = toBsonDoc [(s2L"user", toBson user)] fdb = L.append db (s2L ".system.users")