Implement monger.collection/create
This commit is contained in:
parent
24b2dbe516
commit
1f091ab735
2 changed files with 17 additions and 2 deletions
|
|
@ -205,10 +205,19 @@
|
||||||
(.dropIndexes ^DBCollection (.getCollection monger.core/*mongodb-database* collection)))
|
(.dropIndexes ^DBCollection (.getCollection monger.core/*mongodb-database* collection)))
|
||||||
|
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; monger.collection/exists?, monger.collection/create, monger.collection/drop
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
(defn exists?
|
(defn exists?
|
||||||
[^String collection]
|
[^String collection]
|
||||||
(.collectionExists monger.core/*mongodb-database* collection))
|
(.collectionExists monger.core/*mongodb-database* collection))
|
||||||
|
|
||||||
|
(defn create
|
||||||
|
[^String collection, ^Map options]
|
||||||
|
(.createCollection monger.core/*mongodb-database* collection (to-db-object options)))
|
||||||
|
|
||||||
(defn drop
|
(defn drop
|
||||||
[^String collection]
|
[^String collection]
|
||||||
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)]
|
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)]
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; exists?, drop
|
;; exists?, drop, create
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(deftest checking-for-collection-existence-when-it-does-not-exist
|
(deftest checking-for-collection-existence-when-it-does-not-exist
|
||||||
|
|
@ -397,4 +397,10 @@
|
||||||
(monger.collection/drop collection)
|
(monger.collection/drop collection)
|
||||||
(monger.collection/insert-batch collection [{ :name "widget1" }
|
(monger.collection/insert-batch collection [{ :name "widget1" }
|
||||||
{ :name "widget2" }])
|
{ :name "widget2" }])
|
||||||
(is (monger.collection/exists? collection))))
|
(is (monger.collection/exists? collection))
|
||||||
|
(monger.collection/drop collection)
|
||||||
|
(is (false? (monger.collection/exists? collection)))
|
||||||
|
(monger.collection/create "widgets" { :capped true :max 100 })
|
||||||
|
(is (monger.collection/exists? collection))
|
||||||
|
(monger.collection/drop collection)
|
||||||
|
))
|
||||||
Loading…
Reference in a new issue