{NOTE: }
-
The Session tracks all changes made in all the entities it has either loaded, stored, or queried for,
and persists to the server only what is needed whensaveChanges()
is called. -
This article describes how to check for changes made to all tracked entities within the session.
To check for changes on a specific entity, see Check for entity changes. -
In this page:
{NOTE/}
{PANEL: Check for session changes}
-
The session's advanced property
hasChanges
indicates whether any entities were added, modified, or deleted within the session. -
Note: The hasChanges property is cleared after calling
saveChanges()
.
{CODE:nodejs changes_1@client-api\session\howTo\sessionChanges.js /}
{PANEL/}
{PANEL: Get session changes}
-
Use the session's advanced method
whatChanged()
to get all changes made to all the entities tracked by the session. -
For each entity that was modified, the details will include:
- The name and path of the changed field
- Its old and new values
- The type of change
{CODE:nodejs changes_2@client-api\session\howTo\sessionChanges.js /}
{CODE:nodejs changes_3@client-api\session\howTo\sessionChanges.js /}
{PANEL/}
{PANEL: Syntax}
{CODE:nodejs syntax_1@client-api\session\howTo\sessionChanges.js /} {CODE:nodejs syntax_2@client-api\session\howTo\sessionChanges.js /}
ReturnValue | |
---|---|
Record<string, DocumentsChanges> |
Dictionary containing list of changes per document ID |
DocumentsChanges |
Type | Description |
---|---|---|
fieldOldValue | object | Previous field value |
fieldNewValue | object | Current field value |
change | string | Type of change that occurred. Can be: "DocumentDeleted" , "DocumentAdded" ,"FieldChanged" , "NewField" , "RemovedField" , "ArrayValueChanged" , "ArrayValueAdded" , "ArrayValueRemoved" |
fieldName | string | Name of field on which the change occurred |
fieldPath | string | Path of field on which the change occurred |
fieldFullName | string | Path + Name of field on which the change occurred |
{PANEL/}