How to Get Entity Counters
-
When a document is loaded to the session,
the loaded entity will contain various metadata information such as ID, current change-vector, and more. -
If the document has Counters, the document metadata will also contain its counter names.
The counter names are available for each entity using thegetCountersFor()
method from theadvanced
session operations. -
In this page:
Get entity counters
// Load a document
const employee = await session.load("employees/1-A");
// Get counter names from the loaded entity
const counterNames = session.advanced.getCountersFor(employee);
Syntax
getCountersFor(entity);
Parameter | Type | Description |
---|---|---|
entity | T | The entity for which counter names will be returned. |
Return Type | Description |
---|---|
string[] |
Returns the counter names for the specified entity, or null if the entity has no counters.An exception is thrown if the entity is not tracked by the session. |