DS.SnapshotRecordArray

DS.SnapshotRecordArray Class

PRIVATE

Defined in: addon/-private/system/snapshot-record-array.js:5

Module: ember-data

snapshotsArray

Defined in addon/-private/system/snapshot-record-array.js:123

Get snapshots of the underlying record array

Example

app/adapters/post.js
import DS from 'ember-data'

export default DS.JSONAPIAdapter.extend({
  shouldReloadAll(store, snapshotArray) {
    var snapshots = snapshotArray.snapshots();

    return snapshots.any(function(ticketSnapshot) {
      var timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');
      if (timeDiff > 20) {
        return true;
      } else {
        return false;
      }
    });
  }
});

Returns:

Array
Array of snapshots

_recordArray{Array}private

Defined in addon/-private/system/snapshot-record-array.js:21

An array of records

_snapshots{Array}private

Defined in addon/-private/system/snapshot-record-array.js:14

An array of snapshots

adapterOptions{Object}

Defined in addon/-private/system/snapshot-record-array.js:78

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 MyCustomAdapter.extend({
  findAll(store, type, sinceToken, snapshotRecordArray) {
    if (snapshotRecordArray.adapterOptions.subscribe) {
      // ...
    }
    // ...
  }
});

include{String|Array}

Defined in addon/-private/system/snapshot-record-array.js:101

The relationships to include for this request.

Example

app/adapters/application.js
import DS from 'ember-data';

export default DS.Adapter.extend({
  findAll(store, type, snapshotRecordArray) {
    var url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;

    return fetch(url).then((response) => response.json())
  }
});

length{Number}

Defined in addon/-private/system/snapshot-record-array.js:29

Number of records in the array

Example

app/adapters/post.js
import DS from 'ember-data'

export default DS.JSONAPIAdapter.extend({
  shouldReloadAll(store, snapshotRecordArray) {
    return !snapshotRecordArray.length;
  },
});

meta{Object}

Defined in addon/-private/system/snapshot-record-array.js:56

Meta objects for the record array.

Example

app/adapters/post.js
import DS from 'ember-data'

export default DS.JSONAPIAdapter.extend({
  shouldReloadAll(store, snapshotRecordArray) {
    var lastRequestTime = snapshotRecordArray.meta.lastRequestTime;
    var twentyMinutes = 20 * 60 * 1000;
    return Date.now() > lastRequestTime + twentyMinutes;
  },
});

type{DS.Model}

Defined in addon/-private/system/snapshot-record-array.js:49

The type of the underlying records for the snapshots in the array, as a DS.Model

© 2017 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://emberjs.com/api/data/classes/DS.SnapshotRecordArray.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部