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.