Implement monger.collection/rename
This commit is contained in:
parent
e681bf1a1c
commit
fadf939cd5
2 changed files with 12 additions and 3 deletions
|
|
@ -206,7 +206,7 @@
|
|||
|
||||
|
||||
;;
|
||||
;; monger.collection/exists?, monger.collection/create, monger.collection/drop
|
||||
;; monger.collection/exists?, /create, /drop, /rename
|
||||
;;
|
||||
|
||||
|
||||
|
|
@ -223,6 +223,13 @@
|
|||
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)]
|
||||
(.drop coll)))
|
||||
|
||||
(defn rename
|
||||
([^String from, ^String to]
|
||||
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* from)]
|
||||
(.rename coll to)))
|
||||
([^String from, ^String to, ^Boolean drop-target]
|
||||
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* from)]
|
||||
(.rename coll to drop-target))))
|
||||
|
||||
;;
|
||||
;; Implementation
|
||||
|
|
|
|||
|
|
@ -402,5 +402,7 @@
|
|||
(is (false? (monger.collection/exists? collection)))
|
||||
(monger.collection/create "widgets" { :capped true :max 100 })
|
||||
(is (monger.collection/exists? collection))
|
||||
(monger.collection/drop collection)
|
||||
))
|
||||
(monger.collection/rename collection "gadgets")
|
||||
(is (not (monger.collection/exists? collection)))
|
||||
(is (monger.collection/exists? "gadgets"))
|
||||
(monger.collection/drop "gadgets")))
|
||||
|
|
|
|||
Loading…
Reference in a new issue