Blow the dust off monger.core
This commit is contained in:
parent
4db676657e
commit
63d8e0848f
1 changed files with 23 additions and 6 deletions
|
|
@ -7,10 +7,14 @@
|
||||||
;; the terms of this license.
|
;; the terms of this license.
|
||||||
;; You must not remove this notice, or any other, from this software.
|
;; You must not remove this notice, or any other, from this software.
|
||||||
|
|
||||||
(ns monger.core
|
(ns ^{:author "Michael S. Klishin"
|
||||||
|
:doc "Thin idiomatic wrapper around MongoDB Java client. monger.core includes
|
||||||
|
fundamental functions that work with connections & databases. Most of functionality
|
||||||
|
is in the monger.collection namespace."}
|
||||||
|
monger.core
|
||||||
(:refer-clojure :exclude [count])
|
(:refer-clojure :exclude [count])
|
||||||
(:use [monger.convertion])
|
(:use [monger.convertion])
|
||||||
(:import (com.mongodb Mongo DB WriteConcern DBObject)
|
(:import (com.mongodb Mongo DB WriteConcern DBObject DBCursor)
|
||||||
(java.util Map)))
|
(java.util Map)))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
@ -30,14 +34,27 @@
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(defn ^Mongo connect
|
(defn ^Mongo connect
|
||||||
"Connects to MongoDB"
|
"Connects to MongoDB. When used without arguments, connects to *mongodb-host* and
|
||||||
|
*mongodb-test*.
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
|
||||||
|
(monger.core/connect)
|
||||||
|
(monger.core/connect { :host \"db3.intranet.local\", :port 27787 })
|
||||||
|
"
|
||||||
([]
|
([]
|
||||||
(Mongo.))
|
(Mongo.))
|
||||||
([{ :keys [host port] :or { host *mongodb-host*, port *mongodb-port* }}]
|
([{ :keys [host port] :or { host *mongodb-host*, port *mongodb-port* }}]
|
||||||
(Mongo. #^String host #^Long port)))
|
(Mongo. ^String host ^Long port)))
|
||||||
|
|
||||||
(defn ^DB get-db
|
(defn ^DB get-db
|
||||||
"Get database reference by name"
|
"Get database reference by name.
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
|
||||||
|
(monger.core/get-db \"myapp_production\")
|
||||||
|
(monger.core/get-db connection \"myapp_production\")"
|
||||||
([^String name]
|
([^String name]
|
||||||
(.getDB *mongodb-connection* name))
|
(.getDB *mongodb-connection* name))
|
||||||
([^Mongo connection, ^String name]
|
([^Mongo connection, ^String name]
|
||||||
|
|
@ -49,7 +66,7 @@
|
||||||
(count [this] "Returns size of the object"))
|
(count [this] "Returns size of the object"))
|
||||||
|
|
||||||
(extend-protocol Countable
|
(extend-protocol Countable
|
||||||
com.mongodb.DBCursor
|
DBCursor
|
||||||
(count [^com.mongodb.DBCursor this]
|
(count [^com.mongodb.DBCursor this]
|
||||||
(.count this)))
|
(.count this)))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue