DS.FilteredRecordArray

DS.FilteredRecordArray Class

Extends: DS.RecordArray

Defined in: addon/-private/system/record-arrays/filtered-record-array.js:10

Module: ember-data

Represents a list of records whose membership is determined by the store. As records are created, loaded, or modified, the store evaluates them to determine if they should be part of the record array.

filterFunction (record) Boolean

Defined in addon/-private/system/record-arrays/filtered-record-array.js:27

The filterFunction is a function used to test records from the store to determine if they should be part of the record array.

Example

var allPeople = store.peekAll('person');
allPeople.mapBy('name'); // ["Tom Dale", "Yehuda Katz", "Trek Glowacki"]

var people = store.filter('person', function(person) {
  if (person.get('name').match(/Katz$/)) { return true; }
});
people.mapBy('name'); // ["Yehuda Katz"]

var notKatzFilter = function(person) {
  return !person.get('name').match(/Katz$/);
};
people.set('filterFunction', notKatzFilter);
people.mapBy('name'); // ["Tom Dale", "Trek Glowacki"]

Parameters:

record DS.Model

Returns:

Boolean
`true` if the record should be in the array

updateFilterprivate

Defined in addon/-private/system/record-arrays/filtered-record-array.js:58

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

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部