Liking cljdoc? Tell your friends :D
Clojure only.

com.timezynk.mongo.padding

Pad payload before sending to database.

Pad payload before sending to database.
raw docstring

with-paddingcljmacro

(with-padding {:insert <insert-fn> :update <update-fn> :replace <replace-fn>}
              &
              <body>)

Optional padding of each payload document, before sending to the database.

You may for example want to add a created field for timestamping each inserted document.

ParameterDescription
:insertoptional fn Called for insert!.
:updateoptional fn Called for update!, update-one!, fetch-and-update-one!.
:replaceoptional fn Called for replace-one!, fetch-and-replace-one!.
bodyEncapsulated program calling the database.

Examples

; Add created field:
(with-pads {:insert (fn [doc] (assoc doc :created (System/currentTimeMillis)))}
  (insert! :coll [])) ; Throws exception
Optional padding of each payload document, before sending to the database. 

You may for example want to add a `created` field for timestamping each inserted
document.

| Parameter  | Description
| ---        | ---
| `:insert`  | `optional fn` Called for `insert!`.
| `:update`  | `optional fn` Called for `update!`, `update-one!`, `fetch-and-update-one!`.
| `:replace` | `optional fn` Called for `replace-one!`, `fetch-and-replace-one!`.
| `body`     | Encapsulated program calling the database.

**Examples**

```clojure
; Add created field:
(with-pads {:insert (fn [doc] (assoc doc :created (System/currentTimeMillis)))}
  (insert! :coll [])) ; Throws exception
```
sourceraw 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