From 4fa65114321ae5113e9e98aa015d2820c4d312dc Mon Sep 17 00:00:00 2001 From: Bartek Marcinowski Date: Sun, 7 Jun 2015 21:48:10 +0100 Subject: [PATCH] Add allow-disk-use option to aggregate This commit adds the ability to pass the allowDiskUse option through to MongoDB by adding an additional, optional parameter to the aggregate function. --- src/clojure/monger/collection.clj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/clojure/monger/collection.clj b/src/clojure/monger/collection.clj index 05f7366..157e188 100644 --- a/src/clojure/monger/collection.clj +++ b/src/clojure/monger/collection.clj @@ -24,7 +24,7 @@ * http://clojuremongodb.info/articles/deleting.html * http://clojuremongodb.info/articles/aggregation.html" (:refer-clojure :exclude [find remove count drop distinct empty? update]) - (:import [com.mongodb Mongo DB DBCollection WriteResult DBObject WriteConcern + (:import [com.mongodb Mongo DB DBCollection WriteResult DBObject WriteConcern DBCursor MapReduceCommand MapReduceCommand$OutputType] [java.util List Map] [clojure.lang IPersistentMap ISeq] @@ -494,8 +494,8 @@ "Executes an aggregation query. MongoDB 2.2+ only. See http://docs.mongodb.org/manual/applications/aggregation/ to learn more." - [^DB db ^String coll stages] - (let [res (mc/command db {:aggregate coll :pipeline stages})] + [^DB db ^String coll stages & [^Boolean allow-disk-use]] + (let [res (mc/command db {:aggregate coll :pipeline stages :allowDiskUse (boolean allow-disk-use)})] ;; this is what DBCollection#distinct does. Turning a blind's eye! (.throwOnError res) (map #(from-db-object % true) (.get res "result"))))