Where are the records stored in Ember Data?, part 2

by Kasper Tidemann

Notice: since the time of writing, this has been changed in Ember Data. Please take a look at this post instead.

When working with Ember Data version 0.13, you might want to inspect the records that are stored locally in the browser for debugging purposes or just for peeking at the internals of the persistence layer.

First of all, Ember Data is accessible via the DS namespace in the browser. Ember Data has a default store along with a default transaction that every record belongs to (unless you manually create a transaction). In order to get to the records, calling DS.get('defaultStore.defaultTransaction.records.list') will do the job.

That’s not too useful, however, since it will return all records no matter their state. In earlier versions of Ember Data, the concept of buckets was used to difference between clean records, dirty records, inflight records etc. This no longer applies to Ember Data. Instead, you can use the filterProperty function to return selected records.

A record in Ember Data has a lifecycle. Depending on the state of the record, it will be in either the isLoaded, isDirty, isSaving, isDeleted, isError, isNew, or isValid state. For more info on the record lifecycle, please take a look at the official documentation.

So, back to filterProperty. In order to find all records that have been loaded, just issue this call in your console: DS.get('defaultStore.defaultTransaction.records.list').filterProperty('isLoaded', true). Change isLoaded to any of the other states in order to return the associated records. Et voila!

Notice: this is a follow-up to the original post which is outdated by the time of writing.