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#refresh

DS#refresh(resourceName, id[, options])

Like DS#find, except the item is only re-requested from the adapter if it already exists in the data store.

Returns a promise.

Arguments
nametypedescription
resourceNamestringThe name of the resource to use. Unnecessary if using the resource directly.
idstring or numberThe primary key of the item to retrieve.
optionsobjectConfiguration options. Also passed through to the adapter and (conditionally) to DS.inject.
options.adapterstringOverride the default adapter.
options.cacheResponsebooleanInject the result into the store. Default: true.
Examples
// Exists in the data store, but we want a fresh copy
Document.get(5); // {...}

// Same as store.refresh('document', 5);
Document.refresh(5).then(function (document) {
  document; // The fresh copy, already injected into the store
});
// Does not exist in the data store
Document.get(6); // undefined

Document.refresh(6).then(function (document) {
  document; // undefined
});

📘

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#refresh


DS#refresh(resourceName, id[, options])

Suggested Edits are limited on API Reference Pages

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