From 16e4fdce26c7487fd6a66472748c302d0287525f Mon Sep 17 00:00:00 2001 From: Fujimura Daisuke Date: Sun, 2 Mar 2014 14:54:56 +0900 Subject: [PATCH 1/3] Add type annotations to Example.hs --- doc/Example.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/Example.hs b/doc/Example.hs index 82a87a5..cf244e3 100644 --- a/doc/Example.hs +++ b/doc/Example.hs @@ -3,12 +3,14 @@ import Database.MongoDB import Control.Monad.Trans (liftIO) +main :: IO () main = do pipe <- runIOE $ connect (host "127.0.0.1") e <- access pipe master "baseball" run close pipe print e +run :: Action IO () run = do clearTeams insertTeams @@ -16,18 +18,24 @@ run = do nationalLeagueTeams >>= printDocs "National League Teams" newYorkTeams >>= printDocs "New York Teams" +clearTeams :: Action IO () clearTeams = delete (select [] "team") +insertTeams :: Action IO [Value] insertTeams = insertMany "team" [ ["name" =: "Yankees", "home" =: ["city" =: "New York", "state" =: "NY"], "league" =: "American"], ["name" =: "Mets", "home" =: ["city" =: "New York", "state" =: "NY"], "league" =: "National"], ["name" =: "Phillies", "home" =: ["city" =: "Philadelphia", "state" =: "PA"], "league" =: "National"], ["name" =: "Red Sox", "home" =: ["city" =: "Boston", "state" =: "MA"], "league" =: "American"] ] +allTeams :: Action IO [Document] allTeams = rest =<< find (select [] "team") {sort = ["home.city" =: 1]} +nationalLeagueTeams :: Action IO [Document] nationalLeagueTeams = rest =<< find (select ["league" =: "National"] "team") +newYorkTeams :: Action IO [Document] newYorkTeams = rest =<< find (select ["home.state" =: "NY"] "team") {project = ["name" =: 1, "league" =: 1]} +printDocs :: String -> [Document] -> Action IO () printDocs title docs = liftIO $ putStrLn title >> mapM_ (print . exclude ["_id"]) docs From bccb3bd15964f72109d71f66d032a26d02b7154e Mon Sep 17 00:00:00 2001 From: Fujimura Daisuke Date: Sun, 2 Mar 2014 14:55:15 +0900 Subject: [PATCH 2/3] Do explicit import in Example.hs This will be helpful for the people who is new to this library. --- doc/Example.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/Example.hs b/doc/Example.hs index cf244e3..9908cff 100644 --- a/doc/Example.hs +++ b/doc/Example.hs @@ -1,6 +1,9 @@ {-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-} -import Database.MongoDB +import Database.MongoDB (Action, Document, Document, Value, access, + close, connect, delete, exclude, find, + host, insertMany, master, project, rest, + runIOE, select, sort, (=:)) import Control.Monad.Trans (liftIO) main :: IO () From ea04393c3f276a7e26626bf6c68be399b6371dc6 Mon Sep 17 00:00:00 2001 From: Fujimura Daisuke Date: Sun, 2 Mar 2014 14:56:35 +0900 Subject: [PATCH 3/3] Update repo owner name in README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b1f4453..53c016d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ This is the Haskell MongoDB driver (client). [MongoDB](http://www.mongodb.org) is a free, scalable, fast, document database management system. This driver lets you connect to a MongoDB server, and update and query its data. It also lets you do adminstrative tasks, like create an index or look at performance statistics. ### Documentation -* [Quick example](http://github.com/TonyGen/mongoDB-haskell/blob/master/doc/Example.hs) -* [Tutorial](http://github.com/TonyGen/mongoDB-haskell/blob/master/doc/tutorial.md) +* [Quick example](http://github.com/selectel/mongoDB-haskell/blob/master/doc/Example.hs) +* [Tutorial](http://github.com/selectel/mongoDB-haskell/blob/master/doc/tutorial.md) * [Driver API](http://hackage.haskell.org/package/mongoDB) -* [MapReduce example](http://github.com/TonyGen/mongoDB-haskell/blob/master/doc/map-reduce-example.md) -* [Driver design](http://github.com/TonyGen/mongoDB-haskell/blob/master/doc/Article1.md) +* [MapReduce example](http://github.com/selectel/mongoDB-haskell/blob/master/doc/map-reduce-example.md) +* [Driver design](http://github.com/selectel/mongoDB-haskell/blob/master/doc/Article1.md) * [MongoDB DBMS](http://www.mongodb.org)