monger.core

Thin idiomatic wrapper around MongoDB Java client. monger.core includes
fundamental functions that perform database/replica set connection, set default write concern, default database, performing commands
and so on. Most of the functionality is in other monger.* namespaces, in particular monger.collection, monger.query and monger.gridfs

Related documentation guides:

* http://clojuremongodb.info/articles/connecting.html
* http://clojuremongodb.info/articles/commands.html
* http://clojuremongodb.info/articles/gridfs.html

*mongodb-host*

dynamic

*mongodb-port*

dynamic

*mongodb-write-concern*

dynamic

admin-db

(admin-db conn)
Returns admin database

admin-db-name

command

(command database cmd)
Runs a database command (please check MongoDB documentation for the complete list of commands).

Ordering of keys in the command document may matter. Please use sorted maps instead of map literals, for example:
(array-map :near 50 :test 430 :num 10)

For commonly used commands (distinct, count, map/reduce, etc), use monger.command and monger.collection functions such as
/distinct, /count,  /drop, /dropIndexes, and /mapReduce respectively.

connect

(connect)(connect server-address options)(connect [server-address & more] options)(connect {:keys [host port uri], :or {host *mongodb-host*, port *mongodb-port*}})
Connects to MongoDB. When used without arguments, connects to

Arguments:
  :host ("127.0.0.1" by default)
  :port (27017 by default)

connect-via-uri

(connect-via-uri uri-string)
Connects to MongoDB using a URI, returns the connection and database as a map with :conn and :db.
Commonly used for PaaS-based applications, for example, running on Heroku.
If username and password are provided, performs authentication.

connect-with-credentials

(connect-with-credentials credentials)(connect-with-credentials hostname credentials)(connect-with-credentials hostname port credentials)
Connect with provided credentials and default options

Countable

protocol

members

count

(count this)
Returns size of the object

disconnect

(disconnect conn)
Closes default connection to MongoDB

drop-db

(drop-db conn db)
Drops a database

get-db

(get-db conn name)
Get database reference by name.

get-db-names

(get-db-names conn)
Gets a list of all database names present on the server

get-gridfs

(get-gridfs conn name)
Get GridFS for the given database.

mongo-options

(mongo-options opts)

mongo-options-builder

(mongo-options-builder {:keys [connections-per-host threads-allowed-to-block-for-connection-multiplier max-wait-time connect-timeout socket-timeout socket-keep-alive auto-connect-retry max-auto-connect-retry-time description write-concern cursor-finalizer-enabled read-preference required-replica-set-name]})

raw-command

(raw-command database cmd)
Like monger.core/command but accepts DBObjects

server-address

(server-address hostname)(server-address hostname port)

set-default-write-concern!

(set-default-write-concern! wc)