Implement monger.core/command
This commit is contained in:
parent
1f091ab735
commit
e681bf1a1c
2 changed files with 19 additions and 2 deletions
|
|
@ -9,7 +9,9 @@
|
||||||
|
|
||||||
(ns monger.core
|
(ns monger.core
|
||||||
(:refer-clojure :exclude [count])
|
(:refer-clojure :exclude [count])
|
||||||
(:import (com.mongodb Mongo DB WriteConcern)))
|
(:use [monger.convertion])
|
||||||
|
(:import (com.mongodb Mongo DB WriteConcern DBObject)
|
||||||
|
(java.util Map)))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Defaults
|
;; Defaults
|
||||||
|
|
@ -50,3 +52,8 @@
|
||||||
com.mongodb.DBCursor
|
com.mongodb.DBCursor
|
||||||
(count [^com.mongodb.DBCursor this]
|
(count [^com.mongodb.DBCursor this]
|
||||||
(.count this)))
|
(.count this)))
|
||||||
|
|
||||||
|
|
||||||
|
(defn command
|
||||||
|
[^Map cmd]
|
||||||
|
(.command ^DB *mongodb-database* ^DBObject (to-db-object cmd)))
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
(ns monger.test.core
|
(ns monger.test.core
|
||||||
(:require [monger.core])
|
(:require [monger core collection util])
|
||||||
(:import (com.mongodb Mongo DB))
|
(:import (com.mongodb Mongo DB))
|
||||||
(:use [clojure.test]))
|
(:use [clojure.test]))
|
||||||
|
|
||||||
|
|
||||||
|
(monger.util/with-ns 'monger.core
|
||||||
|
(defonce ^:dynamic *mongodb-connection* (monger.core/connect))
|
||||||
|
(defonce ^:dynamic *mongodb-database* (monger.core/get-db "monger-test")))
|
||||||
|
|
||||||
|
|
||||||
(deftest connect-to-mongo-with-default-host-and-port
|
(deftest connect-to-mongo-with-default-host-and-port
|
||||||
(let [connection (monger.core/connect)]
|
(let [connection (monger.core/connect)]
|
||||||
(is (instance? com.mongodb.Mongo connection))))
|
(is (instance? com.mongodb.Mongo connection))))
|
||||||
|
|
@ -27,3 +33,7 @@
|
||||||
;; (let [connection (monger.core/connect)
|
;; (let [connection (monger.core/connect)
|
||||||
;; db (monger.core/get-db connection "monger-test" "monger" "test_password")]
|
;; db (monger.core/get-db connection "monger-test" "monger" "test_password")]
|
||||||
;; (is (instance? com.mongodb.DB db))))
|
;; (is (instance? com.mongodb.DB db))))
|
||||||
|
|
||||||
|
(deftest issuing-a-profiling-command
|
||||||
|
(let [collection "things"]
|
||||||
|
(monger.core/command { :profile 1 })))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue