js-data

Respect Your Data

Give your data the treatment it deserves with a framework-agnostic, datastore-agnostic JavaScript ORM built for ease of use and peace of mind. Works in Node.js and in the Browser.

Get Started

DS#revert

DS#revert(resourceName, id)

Synchronously revert the state of an item to the last time it was saved via an async adapter. Returns the reverted item.

Arguments
nametypedescription
resourceNamestringThe name of the resource to use. Unnecessary if using the resource directly.
idstring or numberThe primary key of item for which to revert to the previous attributes.
Examples
var d = Document.get(5); // { author: 'John Anderson', id: 5 }

d.author = 'Sally';

d; // { author: 'Sally', id: 5 }

// You may have to do store.digest() first

// same as store.revert('document', 5)
Document.revert(5); // { author: 'John Anderson', id: 5 }

d; // { author: 'John Anderson', id: 5 }

📘

Need help?

Want more examples or have a question? Ask on the Slack channel or post on the mailing list then we'll get your question answered and probably update this wiki.

Updated less than a minute ago

DS#revert


DS#revert(resourceName, id)

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.