Liking cljdoc? Tell your friends :D

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:

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
raw docstring

*mongodb-connection*clj

source

*mongodb-database*clj

source

*mongodb-gridfs*clj

source

*mongodb-host*clj

source

*mongodb-port*clj

source

*mongodb-write-concern*clj

source

admin-dbclj

(admin-db)

Returns admin database

Returns admin database
sourceraw docstring

admin-db-nameclj

source

authenticateclj

(authenticate username password)
(authenticate db username password)
(authenticate connection db username password)
source

commandclj

(command cmd)
(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: (sorted-map geoNear "bars" :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.

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:
(sorted-map geoNear "bars" :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.
sourceraw docstring

connectclj

(connect)
(connect {:keys [host port uri] :or {host *mongodb-host* port *mongodb-port*}})
(connect server-address options)
(connect [server-address & more] options)

Connects to MongoDB. When used without arguments, connects to

Arguments: :host (mongodb-host by default) :port (mongodb-port by default)

EXAMPLES

(monger.core/connect)
(monger.core/connect { :host "db3.intranet.local", :port 27787 })

;; Connecting to a replica set with a couple of seeds
(let [^MongoClientOptions opts (mg/mongo-options :threads-allowed-to-block-for-connection-multiplier 300)
                    seeds [["192.168.1.1" 27017] ["192.168.1.2" 27017] ["192.168.1.1" 27018]]
                    sas (map #(apply mg/server-address %) seeds)]
  (mg/connect! sas opts))
Connects to MongoDB. When used without arguments, connects to

Arguments:
  :host (*mongodb-host* by default)
  :port (*mongodb-port* by default)

EXAMPLES

    (monger.core/connect)
    (monger.core/connect { :host "db3.intranet.local", :port 27787 })

    ;; Connecting to a replica set with a couple of seeds
    (let [^MongoClientOptions opts (mg/mongo-options :threads-allowed-to-block-for-connection-multiplier 300)
                        seeds [["192.168.1.1" 27017] ["192.168.1.2" 27017] ["192.168.1.1" 27018]]
                        sas (map #(apply mg/server-address %) seeds)]
      (mg/connect! sas opts))
sourceraw docstring

connect!clj

(connect! & args)

Connect to MongoDB, store connection in the mongodb-connection var

Connect to MongoDB, store connection in the *mongodb-connection* var
sourceraw docstring

connect-via-uri!clj

(connect-via-uri! uri-string)

Connects to MongoDB using a URI, sets up default connection and database. Commonly used for PaaS-based applications, for example, running on Heroku. If username and password are provided, performs authentication.

Connects to MongoDB using a URI, sets up default connection and database. Commonly used for PaaS-based applications,
for example, running on Heroku. If username and password are provided, performs authentication.
sourceraw docstring

Countablecljprotocol

countclj

(count this)

Returns size of the object

Returns size of the object
source

current-dbclj

(current-db)

Returns currently used database

Returns currently used database
sourceraw docstring

disconnect!clj

(disconnect!)

Closes default connection to MongoDB

Closes default connection to MongoDB
sourceraw docstring

drop-dbclj

(drop-db db)
(drop-db conn db)

Drops a database

Drops a database
sourceraw docstring

get-dbclj

(get-db)
(get-db name)
(get-db connection name)

Get database reference by name.

EXAMPLES

(monger.core/get-db "myapp_production")
(monger.core/get-db connection "myapp_production")
Get database reference by name.

EXAMPLES

    (monger.core/get-db "myapp_production")
    (monger.core/get-db connection "myapp_production")
sourceraw docstring

get-db-namesclj

(get-db-names)
(get-db-names connection)

Gets a list of all database names present on the server

Gets a list of all database names present on the server
sourceraw docstring

get-last-errorclj

(get-last-error)
(get-last-error database)
(get-last-error database write-concern)
(get-last-error database w wtimeout fsync)

Returns the the error (if there is one) from the previous operation on this connection.

The result of this command looks like:

#<CommandResult { "serverUsed" : "127.0.0.1:27017" , "n" : 0 , "connectionId" : 66 , "err" : null , "ok" : 1.0}>"

The value for err will be null if no error occurred, or a description otherwise.

Important note: when calling this method directly, it is undefined which connection "getLastError" is called on. You may need to explicitly use a "consistent Request", see requestStart() For most purposes it is better not to call this method directly but instead use WriteConcern.

Returns the the error (if there is one) from the previous operation on this connection.

The result of this command looks like:

   #<CommandResult { "serverUsed" : "127.0.0.1:27017" , "n" : 0 , "connectionId" : 66 , "err" :  null  , "ok" : 1.0}>"

The value for err will be null if no error occurred, or a description otherwise.

Important note: when calling this method directly, it is undefined which connection "getLastError" is called on.
You may need to explicitly use a "consistent Request", see requestStart() For most purposes it is better not to call this method directly but instead use WriteConcern.
sourceraw docstring

mongo-optionsclj

(mongo-options &
               {: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]
                :or [auto-connect-retry true]})
source

server-addressclj

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

set-connection!clj

(set-connection! conn)

Sets given MongoDB connection as default by altering mongodb-connection var

Sets given MongoDB connection as default by altering *mongodb-connection* var
sourceraw docstring

set-db!clj

(set-db! db)

Sets mongodb-database var to given db, updates mongodb-gridfs var state. Recommended to be used for applications that only use one database.

Sets *mongodb-database* var to given db, updates *mongodb-gridfs* var state. Recommended to be used for
applications that only use one database.
sourceraw docstring

set-default-write-concern!clj

(set-default-write-concern! wc)
source

use-db!clj

Combines set-db! and get-db, so (use-db "mydb") is the same as (set-db! (get-db "mydb"))

Combines set-db! and get-db, so (use-db "mydb") is the same as (set-db! (get-db "mydb"))
sourceraw docstring

with-connectioncljmacro

(with-connection conn & body)
source

with-dbcljmacro

(with-db db & body)
source

with-gridfscljmacro

(with-gridfs fs & body)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close