DocCounter:increment()Add one, visible to every holder of the same prefix. Counts are kept per writer: two sessions writing as the same identity share one count, so their simultaneous increments can collapse into one.
handle3 methods, 1 field
A grow-only counter over one key prefix of a document, shared by every holder of the same prefix. No increment counts twice, whether it was made before the counter opened or after, and the document holds one entry per writer rather than one per increment.
Document:counter| Field | Type | Access | Description |
|---|---|---|---|
value | integer | read-only | The count so far, every writer's increments included. |
DocCounter:increment()Add one, visible to every holder of the same prefix. Counts are kept per writer: two sessions writing as the same identity share one count, so their simultaneous increments can collapse into one.
DocCounter:on_change(callback?: fun(value: integer))Set, replace, or clear (pass nil) the change callback; fired with the new value on every counted increment, yours included.
DocCounter:unsubscribe()Stop listening: the change callback no longer fires, value reads 0 and increment raises. Calling it again does nothing.