Liking cljdoc? Tell your friends :D

com.timezynk.mongo.util

Convenience functions for automating certain tasks.

Convenience functions for automating certain tasks.
raw docstring

make-collection!clj

(make-collection! coll & options)

Try to create a collection. If it already exists, modify it.

Try to create a collection. If it already exists, modify it.
sourceraw docstring

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

wrap-mongocljmacro

(wrap-mongo & <body>)

Functionally set up or change mongodb connection, creating a persistent connection from a previously defined connection string. 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, creating a persistent connection from a previously defined connection string.
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

wrap-requestclj

(wrap-request <handler>)

Wrap a request for a middleware setup

ParameterDescription
handlerfn A request handler function.

Returns

A function that takes a request paramater and makes a call to handler with that request, inside a wrap-mongo call.

Wrap a request for a middleware setup

| Parameter | Description
| ---       | ---
| `handler` | `fn` A request handler function.

**Returns**

A function that takes a `request` paramater and makes a call to `handler` with that request, inside a `wrap-mongo` call.
sourceraw docstring

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

× close