From 94029c7f6cf29d9cd359831ac174ecb1f2653c90 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Tue, 23 Jun 2015 22:01:06 +0300 Subject: [PATCH] Support aggregation options, closes #102 --- src/clojure/monger/collection.clj | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/clojure/monger/collection.clj b/src/clojure/monger/collection.clj index 3466ad7..8569576 100644 --- a/src/clojure/monger/collection.clj +++ b/src/clojure/monger/collection.clj @@ -523,11 +523,13 @@ "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})] - ;; this is what DBCollection#distinct does. Turning a blind's eye! - (.throwOnError res) - (map #(from-db-object % true) (.get res "result")))) + ([^DB db ^String coll stages] + (aggregate db coll stages {})) + ([^DB db ^String coll stages opts] + (let [res (mc/command db (merge {:aggregate coll :pipeline stages} opts))] + ;; this is what DBCollection#distinct does. Turning a blind's eye! + (.throwOnError res) + (map #(from-db-object % true) (.get res "result"))))) ;;