Add call-back functions for listening to query events.
Add call-back functions for listening to query events.
(on-delete <collection> <callback function> & :full? <boolean>)
Listen for an update!
event.
Parameter | Description |
---|---|
collection | keyword/string/nil The collection. If nil it is set for the database. |
callback function | function A callback function that accepts three parameters: |
java.util.Date/custom Time of event, codec-dependent format. | |
map Contains either a single _id field with the id of the deleted document, or the entire deleted document. | |
:full? | optional boolean (>= v6.0) Return complete deleted document. |
Returns
Watch id, which is also the id of the watcher daemon thread. The id is used to close the watcher.
Examples
(defn delete-event [coll time id]
; Do something
)
(on-delete :coll delete-event)
Listen for an `update!` event. | Parameter | Description | --- | --- | `collection` | `keyword/string/nil` The collection. If `nil` it is set for the database. | `callback function` | `function` A callback function that accepts three parameters: | | `java.util.Date/custom` Time of event, codec-dependent format. | | `map` Contains either a single `_id` field with the id of the deleted document, or the entire deleted document. | `:full?` | `optional boolean` (>= v6.0) Return complete deleted document. **Returns** Watch id, which is also the id of the watcher daemon thread. The id is used to close the watcher. **Examples** ```clojure (defn delete-event [coll time id] ; Do something ) (on-delete :coll delete-event) ```
(on-insert <collection>
<callback
function>
&
:collation
<collation
object>
:filter
{})
Listen for an insert!
event.
Parameter | Description |
---|---|
collection | keyword/string/nil The collection. If nil it is set for the database. |
callback function | function A callback function that accepts three parameters: |
keyword The affected collection. | |
java.util.Date/custom Time of event, codec-dependent format. | |
map The inserted document. | |
:collation | optional collation object Collation used. |
:filter | optional map Filter query. |
Returns
Watch id, which is also the id of the watcher daemon thread. The id is used to close the watcher.
Examples
(defn insert-event [coll time doc]
; Do something
)
(on-insert :coll insert-event)
Listen for an `insert!` event. | Parameter | Description | --- | --- | `collection` | `keyword/string/nil` The collection. If `nil` it is set for the database. | `callback function` | `function` A callback function that accepts three parameters: | | `keyword` The affected collection. | | `java.util.Date/custom` Time of event, codec-dependent format. | | `map` The inserted document. | `:collation` | `optional collation object` Collation used. | `:filter` | `optional map` Filter query. **Returns** Watch id, which is also the id of the watcher daemon thread. The id is used to close the watcher. **Examples** ```clojure (defn insert-event [coll time doc] ; Do something ) (on-insert :coll insert-event) ```
(on-replace <collection>
<callback
function>
&
:collation
<collation
object>
:filter {}
:full? <boolean>)
Listen for a replace!
event.
Parameter | Description |
---|---|
collection | keyword/string/nil The collection. If nil it is set for the database. |
callback function | function A callback function that accepts three or four parameters: |
java.util.Date/custom Time of event, codec-dependent format. | |
map The new document. | |
optional map The replaced document. | |
:collation | optional collation object Collation used. |
:filter | optional map Filter query. |
:full? | optional boolean (>= v6.0) Return complete documents after and before change. |
Returns
Watch id, which is also the id of the watcher daemon thread. The id is used to close the watcher.
Examples
(defn update-event [coll time updated-fields]
; Do something
)
(on-update :coll update-event)
Listen for a `replace!` event. | Parameter | Description | --- | --- | `collection` | `keyword/string/nil` The collection. If `nil` it is set for the database. | `callback function` | `function` A callback function that accepts three or four parameters: | | `java.util.Date/custom` Time of event, codec-dependent format. | | `map` The new document. | | `optional map` The replaced document. | `:collation` | `optional collation object` Collation used. | `:filter` | `optional map` Filter query. | `:full?` | `optional boolean` (>= v6.0) Return complete documents after and before change. **Returns** Watch id, which is also the id of the watcher daemon thread. The id is used to close the watcher. **Examples** ```clojure (defn update-event [coll time updated-fields] ; Do something ) (on-update :coll update-event) ```
(on-update <collection>
<callback
function>
&
:collation
<collation
object>
:filter {}
:full? <boolean>)
Listen for an update!
event.
Parameter | Description |
---|---|
collection | keyword/string/nil The collection. If nil it is set for the database. |
callback function | function A callback function that accepts three or four parameters: |
keyword The affected collection. | |
java.util.Date/custom Time of event, codec-dependent format. | |
map Document with changed fields. | |
optional map Old document before changes. | |
:collation | optional collation object Collation used. |
:filter | optional map Filter query. |
:full? | optional boolean (>= v6.0) Return complete documents after and before change. |
Returns
Watch id, which is also the id of the watcher daemon thread. The id is used to close the watcher.
Examples
(defn update-event [coll time updated-fields]
; Do something
)
(on-update :coll update-event)
Listen for an `update!` event. | Parameter | Description | --- | --- | `collection` | `keyword/string/nil` The collection. If `nil` it is set for the database. | `callback function` | `function` A callback function that accepts three or four parameters: | | `keyword` The affected collection. | | `java.util.Date/custom` Time of event, codec-dependent format. | | `map` Document with changed fields. | | `optional map` Old document before changes. | `:collation` | `optional collation object` Collation used. | `:filter` | `optional map` Filter query. | `:full?` | `optional boolean` (>= v6.0) Return complete documents after and before change. **Returns** Watch id, which is also the id of the watcher daemon thread. The id is used to close the watcher. **Examples** ```clojure (defn update-event [coll time updated-fields] ; Do something ) (on-update :coll update-event) ```
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |