You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: How to Refresh an Entity

To update an entity with the latest changes from the server, use the refresh() method from advanced session operations.

Syntax

session.advanced.refresh(entity);

Parameters
entity object Instance of an entity that will be refreshed

Example

const employee = await session.load("employees/1");
assert.strictEqual("Doe", employee.lastName);

// lastName changed to 'Shmoe'

session.advanced.refresh(employee);

assert.strictEqual("Shmoe", employee.lastName);

Remarks

Refreshing a transient entity (not attached) or an entity that was deleted server-side will result in an InvalidOperationException error.