#

API Docs for: v2.11.1
Show: Inherited Protected Private Deprecated

# Ember.DataAdapter Class

Extends EmberObject
Defined in: `packages/ember-extension-support/lib/data_adapter.js:19`
Module: ember-extension-support
Parent Module: ember

The `DataAdapter` helps a data persistence library interface with tools that debug Ember such as the Ember Extension for Chrome and Firefox.

This class will be extended by a persistence library which will override some of the methods with library-specific code.

The methods likely to be overridden are:

- `getFilters`
- `detect`
- `columnsForType`
- `getRecords`
- `getRecordColumnValues`
- `getRecordKeywords`
- `getRecordFilterValues`
- `getRecordColor`
- `observeRecord`

The adapter will need to be registered in the application's container as `dataAdapter:main`.

Example:

    Application.initializer({
      name: "data-adapter",

      initialize: function(application) {
        application.register('data-adapter:main', DS.DataAdapter);
      }
    });

- Index
- Methods
- Properties

## Item Index

### Methods

- _getObjectsOnNamespaces
- columnsForType
- detect
- getFilters
- getModelTypes
- getRecordColor
- getRecordColumnValues
- getRecordFilterValues
- getRecordKeywords
- getRecords
- observeModelType
- observerRecord
- watchModelTypes
- watchRecords
- willDestroy
- wrapModelType
- wrapRecord

### Properties

- acceptsModelName
- attributeLimit
- containerDebugAdapter
- releaseMethods

## Methods

### `_getObjectsOnNamespaces`

() Array private

Defined in `packages/ember-extension-support/lib/data_adapter.js:371`

Loops over all namespaces and all objects attached to them.

#### Returns:

Array:

Array of model type strings.

### `columnsForType`

(

- `type`

)
Array private

Defined in `packages/ember-extension-support/lib/data_adapter.js:263`

Get the columns for a given model type.

#### Parameters:

- `type` Class

  The model type.

#### Returns:

Array:

An array of columns of the following format: name: {String} The name of the column. desc: {String} Humanized description (what would show in a table column name).

### `detect`

(

- `klass`

)
private

Defined in `packages/ember-extension-support/lib/data_adapter.js:248`

Detect whether a class is a model.

Test that against the model class of your persistence library.

#### Parameters:

- `klass` Class

  The class to test.

#### Returns:

boolean Whether the class is a model class or not.

### `getFilters`

() Array public

Defined in `packages/ember-extension-support/lib/data_adapter.js:114`

Specifies how records can be filtered. Records returned will need to have a `filterValues` property with a key for every name in the returned array.

#### Returns:

Array:

List of objects defining filters. The object should have a `name` and `desc` property.

### `getModelTypes`

() Array private

Defined in `packages/ember-extension-support/lib/data_adapter.js:342`

Fetches all models defined in the application.

#### Returns:

Array:

Array of model types.

### `getRecordColor`

(

- `record`

)
String private

Defined in `packages/ember-extension-support/lib/data_adapter.js:469`

Each record can have a color that represents its state.

#### Parameters:

- `record` Object

  The record instance

#### Returns:

String:

The records color. Possible options: black, red, blue, green.

### `getRecordColumnValues`

() Object private

Defined in `packages/ember-extension-support/lib/data_adapter.js:434`

Gets the values for each column.

#### Returns:

Object:

Keys should match column names defined by the model type.

### `getRecordFilterValues`

(

- `record`

)
Object private

Defined in `packages/ember-extension-support/lib/data_adapter.js:457`

Returns the values of filters defined by `getFilters`.

#### Parameters:

- `record` Object

  The record instance.

#### Returns:

Object:

The filter values.

### `getRecordKeywords`

() Array private

Defined in `packages/ember-extension-support/lib/data_adapter.js:446`

Returns keywords to match when searching records.

#### Returns:

Array:

Relevant keywords for search.

### `getRecords`

() Array private

Defined in `packages/ember-extension-support/lib/data_adapter.js:400`

Fetches all loaded records for a given type.

#### Returns:

Array:

An array of records. This array will be observed for changes, so it should update when new records are added/removed.

### `observeModelType`

(

- `modelName`
- `typesUpdated`

)
Function private

Defined in `packages/ember-extension-support/lib/data_adapter.js:277`

Adds observers to a model type class.

#### Parameters:

- `modelName` String

  The model type name.

- `typesUpdated` Function

  Called when a type is modified.

#### Returns:

Function:

The function to call to remove observers.

### `observerRecord`

(

- `record`
- `recordUpdated`

)
Function private

Defined in `packages/ember-extension-support/lib/data_adapter.js:482`

Observes all relevant properties and re-sends the wrapped record when a change occurs.

#### Parameters:

- `record` Object

  The record instance.

- `recordUpdated` Function

  The callback to call when a record is updated.

#### Returns:

Function:

The function to call to remove all observers.

### `watchModelTypes`

(

- `typesAdded`
- `typesUpdated`

)
Function public

Defined in `packages/ember-extension-support/lib/data_adapter.js:128`

Fetch the model types and observe them for changes.

#### Parameters:

- `typesAdded` Function

  Callback to call to add types. Takes an array of objects containing wrapped types (returned from `wrapModelType`).

- `typesUpdated` Function

  Callback to call when a type has changed. Takes an array of objects containing wrapped types.

#### Returns:

Function:

Method to call to remove all observers

### `watchRecords`

(

- `modelName`
- `recordsAdded`
- `recordsUpdated`
- `recordsRemoved`

)
Function public

Defined in `packages/ember-extension-support/lib/data_adapter.js:171`

Fetch the records of a given type and observe them for changes.

#### Parameters:

- `modelName` String

  The model name.

- `recordsAdded` Function

  Callback to call to add records. Takes an array of objects containing wrapped records. The object should have the following properties: columnValues: {Object} The key and value of a table cell. object: {Object} The actual record object.

- `recordsUpdated` Function

  Callback to call when a record has changed. Takes an array of objects containing wrapped records.

- `recordsRemoved` Function

  Callback to call when a record has removed. Takes the following parameters: index: The array index where the records were removed. count: The number of records removed.

#### Returns:

Function:

Method to call to remove all observers.

### `willDestroy`

() private

Defined in `packages/ember-extension-support/lib/data_adapter.js:238`

Clear all observers before destruction

### `wrapModelType`

(

- `klass`
- `modelName`

)
Object private

Defined in `packages/ember-extension-support/lib/data_adapter.js:310`

Wraps a given model type and observes changes to it.

#### Parameters:

- `klass` Class

  A model class.

- `modelName` String

  Name of the class.

#### Returns:

Object:

Contains the wrapped type and the function to remove observers Format: type: {Object} The wrapped type. The wrapped type has the following format: name: {String} The name of the type. count: {Integer} The number of records available. columns: {Columns} An array of columns to describe the record. object: {Class} The actual Model type class. release: {Function} The function to remove observers.

### `wrapRecord`

(

- `record`

)
Object private

Defined in `packages/ember-extension-support/lib/data_adapter.js:413`

Wraps a record and observers changes to it.

#### Parameters:

- `record` Object

  The record instance.

#### Returns:

Object:

The wrapped record. Format: columnValues: {Array} searchKeywords: {Array}

## Properties

### `acceptsModelName`

Unknown public

Defined in `packages/ember-extension-support/lib/data_adapter.js:90`

Ember Data > v1.0.0-beta.18 requires string model names to be passed around instead of the actual factories.

This is a stamp for the Ember Inspector to differentiate between the versions to be able to support older versions too.

### `attributeLimit`

Unknown private

Defined in `packages/ember-extension-support/lib/data_adapter.js:78`

Available since 1.3.0

The number of attributes to send as columns. (Enough to make the record identifiable).

Default: 3

### `containerDebugAdapter`

Unknown public

Defined in `packages/ember-extension-support/lib/data_adapter.js:67`

Available since 1.5.0

The container-debug-adapter which is used to list all models.

Default: undefined

### `releaseMethods`

Unknown private

Defined in `packages/ember-extension-support/lib/data_adapter.js:104`

Available since 1.3.0

Stores all methods that clear observers. These methods will be called on destruction.