diff --git a/src/monger/collection.clj b/src/monger/collection.clj new file mode 100644 index 0000000..a19c3e5 --- /dev/null +++ b/src/monger/collection.clj @@ -0,0 +1,11 @@ +(ns monger.collection + (:import (com.mongodb Mongo DB)) + ) + +;; +;; API +;; + +(defn ^long count + [^DB db, ^String collection] + (.count (.getCollection db collection))) diff --git a/test/monger/test/collection.clj b/test/monger/test/collection.clj new file mode 100644 index 0000000..04b6e9e --- /dev/null +++ b/test/monger/test/collection.clj @@ -0,0 +1,9 @@ +(ns monger.test.collection + (:require [monger core collection]) + (:use [clojure.test])) + +(deftest get-collection-size + (let [connection (monger.core/connect) + db (monger.core/get-db connection "monger-test")] + (is 0 (monger.collection/count db "things")))) +