You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 5.1 version.
Session: How to Get Entity Change-Vector
The change-vector reflects the cluster-wide point in time where something happened. It includes the unique database ID, node identifier, and the Etag of the document in the specific node.
When a document is downloaded from the server, it contains various metadata information e.g. ID or current change-vector. Current change-vector is stored within the metadata in session and is available for each entity using the getChangeVectorFor()
method from the advanced
session operations.
Syntax
session.advanced.getChangeVectorFor(entity);
Parameters | ||
---|---|---|
instance | object | Instance of an entity for which an Etag will be returned. |
Return Value | |
---|---|
string | Returns the current change-vector for an entity. Throws an exception if the instance is not tracked by the session. |
Example
const employee = await session.load("employees/1-A");
const changeVector = session.advanced.getChangeVectorFor(employee);