SnapshotRecordArray Class
SnapshotRecordArray is not directly instantiable. Instances are provided to consuming application's adapters for certain requests.
Item Index
Methods
Properties
Methods
constructor
(
private
-
store
-
type
-
options
SnapshotRecordArray is not directly instantiable. Instances are provided to consuming application's adapters and serializers for certain requests.
Parameters:
-
store
Store -
type
String -
options
Object
snapshots
()
Array
public
Get snapshots of the underlying record array
Example
import JSONAPIAdapter from '@ember-data/adapter/json-api';
export default class PostAdapter extends JSONAPIAdapter {
shouldReloadAll(store, snapshotArray) {
let snapshots = snapshotArray.snapshots();
return snapshots.any(function(ticketSnapshot) {
let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');
if (timeDiff > 20) {
return true;
} else {
return false;
}
});
}
}
Returns:
Array:
Array of snapshots
Properties
_recordArray
Array
private
An array of records
_snapshots
Array
private
An array of snapshots
adapterOptions
Object
public
A hash of adapter options passed into the store method for this request.
Example
import MyCustomAdapter from './custom-adapter';
export default class PostAdapter extends MyCustomAdapter {
findAll(store, type, sinceToken, snapshotRecordArray) {
if (snapshotRecordArray.adapterOptions.subscribe) {
// ...
}
// ...
}
}
include
String | Array
public
The relationships to include for this request.
Example
import Adapter from '@ember-data/adapter';
export default class ApplicationAdapter extends Adapter {
findAll(store, type, snapshotRecordArray) {
let url = /${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}
;
return fetch(url).then((response) => response.json())
}
}
length
Number
public
Number of records in the array
Example
import JSONAPIAdapter from '@ember-data/adapter/json-api';
export default class PostAdapter extends JSONAPIAdapter {
shouldReloadAll(store, snapshotRecordArray) {
return !snapshotRecordArray.length;
}
});
modelName
Model
public
The modelName of the underlying records for the snapshots in the array, as a Model