Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:url "https://www.eclipse.org/legal/epl-2.0/"}
:signing {:gpg-key "helpshift-clojars-admin"}
:dependencies [[org.clojure/clojure "1.10.0"]
[org.mongodb/mongodb-driver-sync "4.1.1"]
[org.mongodb/mongodb-driver-sync "4.8.0"]
[org.clojure/tools.logging "1.1.0"]]
:repl-options {:init-ns mongrove.core}
:jvm-opts ^:replace ["-Duser.timezone=UTC"
Expand Down
17 changes: 17 additions & 0 deletions src/mongrove/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,23 @@
(.countDocuments collection bson-query)))))


(defn ^:public-api distinct-vals
"Gets the distinct values for a field name that matches the filter."
([^MongoDatabase db
^String coll
^String field-name
^Class class-type
filter & {:keys [session]}]
(let [collection (get-collection db coll)
bson-filter (conversion/to-bson-document filter)
^DistinctIterable iterator
(if session
(.distinct ^MongoCollection collection session field-name bson-filter class-type)
(.distinct ^MongoCollection collection field-name bson-filter class-type))
cursor (.cursor iterator)]
(iterator-seq cursor))))


(defn ^:public-api delete
"Delete a document from the collection that matches `query`.
wc is the write-concern which should be a key from write-concern-map and is optional.
Expand Down