counters.inc(name, value, [counterFile]) Last updated: 10. Dec 2024

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 integer The value to increment the counter by.
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");
return { "ticketno": ticketno };