Class SnapshotRecordArray

public

SnapshotRecordArray is not directly instantiable. Instances are provided to consuming application's adapters for certain findAll requests.

returns
Array

Array of snapshots

Get snapshots of the underlying record array

Example

app/adapters/post.js
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;
      }
    });
  }
}

A hash of adapter options passed into the store method for this request.

Example

app/adapters/post.js
import MyCustomAdapter from './custom-adapter';

export default class PostAdapter extends MyCustomAdapter {
  findAll(store, type, sinceToken, snapshotRecordArray) {
    if (snapshotRecordArray.adapterOptions.subscribe) {
      // ...
    }
    // ...
  }
}

The relationships to include for this request.

Example

app/adapters/application.js
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())
  }
}

Number of records in the array

Example

app/adapters/post.js
import JSONAPIAdapter from '@ember-data/adapter/json-api';

export default class PostAdapter extends JSONAPIAdapter {
  shouldReloadAll(store, snapshotRecordArray) {
    return !snapshotRecordArray.length;
  }
});

The modelName of the underlying records for the snapshots in the array, as a Model