Permalink
Browse files

use ExtendedDefaultRules in example

  • Loading branch information...
1 parent c2ca221 commit e152f5b69b3e080bc3e1ef9ac57a147eb505b8c6 Tony Hannan committed Jul 30, 2011
Showing with 17 additions and 17 deletions.
  1. +9 −9 Database/MongoDB.hs
  2. +8 −8 doc/Example.hs
  3. BIN doc/MongoDBIntro.pptx
View
@@ -1,9 +1,9 @@
{- |
Client interface to MongoDB database management system.
-Simple example below. Use with language extension /OvererloadedStrings/.
+Simple example below. Use with language extensions /OvererloadedStrings/ & /ExtendedDefaultRules/.
-> {-# LANGUAGE OverloadedStrings #-}
+> {-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-}
>
> import Database.MongoDB
> import Control.Monad.Trans (liftIO)
@@ -24,16 +24,16 @@ Simple example below. Use with language extension /OvererloadedStrings/.
> clearTeams = delete (select [] "team")
>
> insertTeams = insertMany "team" [
-> ["name" =: u"Yankees", "home" =: ["city" =: u"New York", "state" =: u"NY"], "league" =: u"American"],
-> ["name" =: u"Mets", "home" =: ["city" =: u"New York", "state" =: u"NY"], "league" =: u"National"],
-> ["name" =: u"Phillies", "home" =: ["city" =: u"Philadelphia", "state" =: u"PA"], "league" =: u"National"],
-> ["name" =: u"Red Sox", "home" =: ["city" =: u"Boston", "state" =: u"MA"], "league" =: u"American"] ]
+> ["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 = rest =<< find (select [] "team") {sort = ["home.city" =: (1 :: Int)]}
+> allTeams = rest =<< find (select [] "team") {sort = ["home.city" =: 1]}
>
-> nationalLeagueTeams = rest =<< find (select ["league" =: u"National"] "team")
+> nationalLeagueTeams = rest =<< find (select ["league" =: "National"] "team")
>
-> newYorkTeams = rest =<< find (select ["home.state" =: u"NY"] "team") {project = ["name" =: (1 :: Int), "league" =: (1 :: Int)]}
+> newYorkTeams = rest =<< find (select ["home.state" =: "NY"] "team") {project = ["name" =: 1, "league" =: 1]}
>
> printDocs title docs = liftIO $ putStrLn title >> mapM_ (print . exclude ["_id"]) docs
>
View
@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-}
import Database.MongoDB
import Control.Monad.Trans (liftIO)
@@ -19,15 +19,15 @@ run = do
clearTeams = delete (select [] "team")
insertTeams = insertMany "team" [
- ["name" =: u"Yankees", "home" =: ["city" =: u"New York", "state" =: u"NY"], "league" =: u"American"],
- ["name" =: u"Mets", "home" =: ["city" =: u"New York", "state" =: u"NY"], "league" =: u"National"],
- ["name" =: u"Phillies", "home" =: ["city" =: u"Philadelphia", "state" =: u"PA"], "league" =: u"National"],
- ["name" =: u"Red Sox", "home" =: ["city" =: u"Boston", "state" =: u"MA"], "league" =: u"American"] ]
+ ["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 = rest =<< find (select [] "team") {sort = ["home.city" =: (1 :: Int)]}
+allTeams = rest =<< find (select [] "team") {sort = ["home.city" =: 1]}
-nationalLeagueTeams = rest =<< find (select ["league" =: u"National"] "team")
+nationalLeagueTeams = rest =<< find (select ["league" =: "National"] "team")
-newYorkTeams = rest =<< find (select ["home.state" =: u"NY"] "team") {project = ["name" =: (1 :: Int), "league" =: (1 :: Int)]}
+newYorkTeams = rest =<< find (select ["home.state" =: "NY"] "team") {project = ["name" =: 1, "league" =: 1]}
printDocs title docs = liftIO $ putStrLn title >> mapM_ (print . exclude ["_id"]) docs
View
Binary file not shown.

0 comments on commit e152f5b

Please sign in to comment.