mongoDB 1.3.2 → 1.4.0
raw patch · 2 files changed
+17/−1 lines, 2 files
Files
- Database/MongoDB/Query.hs +16/−0
- mongoDB.cabal +1/−1
Database/MongoDB/Query.hs view
@@ -30,6 +30,8 @@ explain, find, findOne, fetch, count, distinct, -- *** Cursor Cursor, nextBatch, next, nextN, rest, closeCursor, isCursorClosed,+ -- ** Aggregate+ Pipeline, aggregate, -- ** Group Group(..), GroupKey(..), group, -- ** MapReduce@@ -123,6 +125,7 @@ | QueryFailure ErrorCode String -- ^ Query failed for some reason as described in the string | WriteFailure ErrorCode String -- ^ Error observed by getLastError after a write, error description is in string | DocNotFound Selection -- ^ 'fetch' found no document matching selection+ | AggregateFailure String -- ^ 'aggregate' returned an error deriving (Show, Eq) type ErrorCode = Int@@ -579,6 +582,19 @@ isCursorClosed (Cursor _ _ var) = do Batch _ cid docs <- fulfill =<< readMVar var return (cid == 0 && null docs)++-- ** Aggregate++type Pipeline = [Document]+-- ^ The Aggregate Pipeline++aggregate :: MonadIO' m => Collection -> Pipeline -> Action m [Document]+-- ^ Runs an aggregate and unpacks the result. See <http://docs.mongodb.org/manual/core/aggregation/> for details.+aggregate aColl agg = do+ response <- runCommand ["aggregate" =: aColl, "pipeline" =: agg]+ case true1 "ok" response of+ True -> lookup "result" response+ False -> throwError $ AggregateFailure $ at "errmsg" response -- ** Group
mongoDB.cabal view
@@ -1,5 +1,5 @@ Name: mongoDB-Version: 1.3.2+Version: 1.4.0 Synopsis: Driver (client) for MongoDB, a free, scalable, fast, document DBMS Description: This package lets you connect to MongoDB servers and