DS.FilteredRecordArray Class
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.
Item Index
Methods
Properties
Methods
_pushInternalModels
(
private
-
internalModel
Adds an internal model to the
RecordArray
without duplicates
Parameters:
-
internalModel
InternalModel
_unregisterFromManager
()
private
filterFunction
(
Boolean
-
record
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
objectAtContent
(
DS.Model
private
-
index
Retrieves an object from the content by index.
Parameters:
-
index
Number
Returns:
DS.Model:
record
removeInternalModel
(
private
-
internalModel
Removes an internalModel to the
RecordArray
.
Parameters:
-
internalModel
InternalModel
save
()
DS.PromiseArray
Saves all of the records in the
RecordArray
.
Example
`
javascript
var messages = store.peekAll('message');
messages.forEach(function(message) {
message.set('hasBeenSeen', true);
});
messages.save();
`
Returns:
DS.PromiseArray:
promise
update
()
Used to get the latest version of all of the records in this array
from the adapter.
Example
`
javascript
var people = store.peekAll('person');
people.get('isUpdating'); // false
people.update().then(function() {
people.get('isUpdating'); // false
});
people.get('isUpdating'); // true
`
updateFilter
()
private
Properties
content
Ember.Array
private
The array of client ids backing the record array. When a
record is requested from the record array, the record
for the client id at the same index is materialized, if
necessary, by the store.
isLoaded
Boolean
The flag to signal a
RecordArray
is finished loading data.
Example
`
javascript
var people = store.peekAll('person');
people.get('isLoaded'); // true
`
isUpdating
Boolean
The flag to signal a
RecordArray
is currently loading data.
Example
`
javascript
var people = store.peekAll('person');
people.get('isUpdating'); // false
people.update();
people.get('isUpdating'); // true
`