Liking cljdoc? Tell your friends :D

com.timezynk.mongo.util

Convenience functions for automating certain tasks.

Convenience functions for automating certain tasks.
raw docstring

->stringcljmultimethod


discard-index!clj

(discard-index! coll index)

Try to drop an index. If it doesn't exist, ignore the exception.

Try to drop an index. If it doesn't exist, ignore the exception.
raw docstring

make-collection!cljmacro

(make-collection! coll & {:as options})

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

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

make-insert!clj

(make-insert! coll doc)

This is identical to insert!, except if payload is nil, return nil instead of throwing exception. Use this function when the payload is expected to be a nil-able document.

This is identical to `insert!`, except if payload is nil, return nil instead of throwing exception.
Use this function when the payload is expected to be a nil-able document.
raw docstring

object-id?cljmultimethod


random-stringclj

(random-string size)

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

ToObjectIdcljprotocol

->object-idclj

(->object-id v)

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))
```
raw 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.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close