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.
This commit is contained in:
Bartek Marcinowski 2015-06-07 21:48:10 +01:00
parent 9cb54167c4
commit 4fa6511432

View file

@ -24,7 +24,7 @@
* http://clojuremongodb.info/articles/deleting.html * http://clojuremongodb.info/articles/deleting.html
* http://clojuremongodb.info/articles/aggregation.html" * http://clojuremongodb.info/articles/aggregation.html"
(:refer-clojure :exclude [find remove count drop distinct empty? update]) (: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] DBCursor MapReduceCommand MapReduceCommand$OutputType]
[java.util List Map] [java.util List Map]
[clojure.lang IPersistentMap ISeq] [clojure.lang IPersistentMap ISeq]
@ -494,8 +494,8 @@
"Executes an aggregation query. MongoDB 2.2+ only. "Executes an aggregation query. MongoDB 2.2+ only.
See http://docs.mongodb.org/manual/applications/aggregation/ to learn more." See http://docs.mongodb.org/manual/applications/aggregation/ to learn more."
[^DB db ^String coll stages] [^DB db ^String coll stages & [^Boolean allow-disk-use]]
(let [res (mc/command db {:aggregate coll :pipeline stages})] (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! ;; this is what DBCollection#distinct does. Turning a blind's eye!
(.throwOnError res) (.throwOnError res)
(map #(from-db-object % true) (.get res "result")))) (map #(from-db-object % true) (.get res "result"))))