Session: How to Check if Entity has Changed
To check if a specific entity differs from the one downloaded from server, the hasChanged()
method from the advanced
session operations can be used.
Syntax
session.advanced.hasChanged(entity);
Parameters
entity
object
Entity for which changes will be checked.
Return Value
boolean
Indicates whether given entity has changed.
Example
const employee = await session.load("employees/1-A");
let hasChanged = session.advanced.hasChanged(employee); // false
employee.lastName = "Shmoe";
hasChanged = session.advanced.hasChanged(employee); // true
Please enable JavaScript to view the comments powered by Disqus.