From 8ee5b8f71700262e80f6e3383fbde2eae2176647 Mon Sep 17 00:00:00 2001 From: "Michael S. Klishin" Date: Thu, 4 Aug 2011 18:06:13 +0400 Subject: [PATCH] Introduce monger.collection/count --- src/monger/collection.clj | 11 +++++++++++ test/monger/test/collection.clj | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/monger/collection.clj create mode 100644 test/monger/test/collection.clj 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")))) +