counters.inc(name, [value], [counterFile]) Last updated: 30. May 2026

API only function

Thread safe function managing a counter by name. Increments counter value and returns new value. If counter not set, starts at value 1.

Parameters

Name Type Description
name string

The unique identifier for the counter.

value (optional) integer

The value to increment the counter by.
Default 1.

counterFile (optional) string

Absolute file path to counter file.
Default is "#/counters.json" if not specified.

Returns

The incremented counter integer value.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
let ticketno = counters.inc("Ticketno");
let counter2 = counters.inc("Counter2", 2);
let counter3 = counters.inc("Counter3", 3, "#/Counters/My counter.json");

return { "ticketno": ticketno, "counter2" : counter2, "counter3" : counter3 };