(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. |
(swallow & body)Any exception in body gets eaten and macro returns nil.
Returns
Normal execution: The result of the last encapsulated expression.
Exception: nil.
Any exception in body gets eaten and macro returns `nil`. **Returns** Normal execution: The result of the last encapsulated expression. Exception: `nil`.
(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 builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |