Introduce monger.collection/count

This commit is contained in:
Michael S. Klishin 2011-08-04 18:06:13 +04:00
parent 1299aecb3a
commit 8ee5b8f717
2 changed files with 20 additions and 0 deletions

11
src/monger/collection.clj Normal file
View file

@ -0,0 +1,11 @@
(ns monger.collection
(:import (com.mongodb Mongo DB))
)
;;
;; API
;;
(defn ^long count
[^DB db, ^String collection]
(.count (.getCollection db collection)))

View file

@ -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"))))