Also known as listeners or triggers, these functions allow you to monitor collection activity; Each time a document is inserted, updated, replaced, or deleted, a call-back function is invoked.
Every document triggers its own event.
Note Each watcher runs in a separate worker thread.
(require '[com.timezynk.mongo.watch :as w])
(defn insert-fn [token time coll doc]
())
(w/on-insert :coll insert-fn)
Each of the trigger functions – on-insert, on-update, on-replace, on-delete – accepts a call-back function that must take three to five parameters:
token The resume token, a unique string for the event.
time Operation time, expressed as a java.util.Date object.
collection The affected collection.
document A map containing either:
[on insert] The inserted document including the newly created :_id field.
[on update] Either a delta with :_id, :update, :remove fields, or the full updated document.
[on replace] The new document.
[on delete] A document with either the :_id field or the full deleted document.
optional document On update and replace, the old document.
Can you improve this documentation? These fine people already did:
Lars & lars-timezynkEdit on Codeberg
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 |