(set-mongo-uri! <uri>)
Set connection string prior to creating a persistent binding.
Parameter | Description |
---|---|
uri | string Database location. |
Set connection string prior to creating a persistent binding. | Parameter | Description | | --- | --- | | `uri` | `string` Database location. |
(wrap-mongo & <body>)
Functionally set up or change mongodb connection, using a persistent connection. Reverts to earlier settings when leaving scope.
set-mongo-uri!
.MONGO_URI
environment variable.The connection string is used only once to set up the persistent connection.
Parameter | Description |
---|---|
body | Encapsulated program calling the database. |
Returns
The result of the last encapsulated expression.
Examples
(set-mongo-uri! "mongodb://localhost:27017/my-database")
(wrap-mongo
(insert! :users {:name "My Name"})
(fetch! :users))
Functionally set up or change mongodb connection, using a persistent connection. Reverts to earlier settings when leaving scope. 1. Looks for a connection string set by a prior call to `set-mongo-uri!`. 2. Failing that, retrieves a connection string `MONGO_URI` environment variable. The connection string is used only once to set up the persistent connection. | Parameter | Description | | --- | --- | | `body` | Encapsulated program calling the database. | **Returns** The result of the last encapsulated expression. **Examples** ```Clojure (set-mongo-uri! "mongodb://localhost:27017/my-database") (wrap-mongo (insert! :users {:name "My Name"}) (fetch! :users)) ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close