(ignore-hooks & <body>)
If any hooks are set, ignore them.
Parameter | Description |
---|---|
body | Encapsulated program for which database hooks are to be ignored. |
If any hooks are set, ignore them. | Parameter | Description | | --- | --- | | `body` | Encapsulated program for which database hooks are to be ignored. |
(with-hooks {:read <read-fn> :write <write-fn>} & <body>)
Insert hooks for converting documents. The <read-fn> function will be called for each document returned from MongoDB; the <write-fn> will be called for each document sent to MongoDB, both for the query and for the payload.
The hook is applied recursively to nested documents.
Parameter | Description |
---|---|
:read | optional fn Called when returning a document from MongoDB. |
:write | optional fn Called for a query or payload to MongoDB. |
body | Encapsulated program calling the database. |
Examples
; When a document is written to the database, replace the field 'name' with 'username':
(with-hooks {:write #(clojure.set/rename-keys % {:name :username})}
(insert! :coll {:name "My Name"}))
Insert hooks for converting documents. The <read-fn> function will be called for each document returned from MongoDB; the <write-fn> will be called for each document sent to MongoDB, both for the query and for the payload. The hook is applied recursively to nested documents. | Parameter | Description | | --- | --- | | `:read` | `optional fn` Called when returning a document from MongoDB. | | `:write` | `optional fn` Called for a query or payload to MongoDB. | | `body` | Encapsulated program calling the database. | **Examples** ```Clojure ; When a document is written to the database, replace the field 'name' with 'username': (with-hooks {:write #(clojure.set/rename-keys % {:name :username})} (insert! :coll {:name "My Name"})) ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close