packages feed

mongoDB 1.0.1 → 1.0.2

raw patch · 3 files changed

+12/−12 lines, 3 files

Files

Database/MongoDB.hs 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 @@ > 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 >
Database/MongoDB/Query.hs view
@@ -40,7 +40,7 @@  import Prelude as X hiding (lookup) import Data.UString as U (UString, dropWhile, any, tail)-import Data.Bson (Document, at, lookup, look, Field(..), (=:), (=?), Label, Value(String,Doc), Javascript, genObjectId)+import Data.Bson (Document, at, valueAt, lookup, look, Field(..), (=:), (=?), Label, Value(String,Doc), Javascript, genObjectId) import Database.MongoDB.Internal.Protocol (Pipe, Notice(..), Request(GetMore), Reply(..), QueryOption(..), ResponseFlag(..), InsertOption(..), UpdateOption(..), DeleteOption(..), CursorId, FullCollection, Username, Password, pwKey) import qualified Database.MongoDB.Internal.Protocol as P (send, call, Request(Query)) import Database.MongoDB.Internal.Util (MonadIO', loop, liftIOE, true1, (<.>))@@ -274,7 +274,7 @@ 	db <- thisDatabase 	docs' <- liftIO $ mapM assignId docs 	write (Insert (db <.> col) opts docs')-	mapM (look "_id") docs'+	return $ map (valueAt "_id") docs'  assignId :: Document -> IO Document -- ^ Assign a unique value to _id field if missing
mongoDB.cabal view
@@ -1,5 +1,5 @@ name: mongoDB-version: 1.0.1+version: 1.0.2 build-type: Simple license: OtherLicense license-file: LICENSE