Liking cljdoc? Tell your friends :D

com.timezynk.mongo.util


set-mongo-uri!clj

(set-mongo-uri! <uri>)

Set connection string prior to creating a persistent binding.

ParameterDescription
uristring Database location.
Set connection string prior to creating a persistent binding.

| Parameter | Description |
| ---       | --- |
| `uri`     | `string` Database location. |
sourceraw docstring

swallowcljmacro

(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`.
sourceraw docstring

wrap-mongocljmacro

(wrap-mongo & <body>)

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.

ParameterDescription
bodyEncapsulated 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))
```
sourceraw docstring

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

× close