Introduce monger.collection/count
This commit is contained in:
parent
1299aecb3a
commit
8ee5b8f717
2 changed files with 20 additions and 0 deletions
11
src/monger/collection.clj
Normal file
11
src/monger/collection.clj
Normal 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)))
|
||||
9
test/monger/test/collection.clj
Normal file
9
test/monger/test/collection.clj
Normal 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"))))
|
||||
|
||||
Loading…
Reference in a new issue