Class Adapter

public

An adapter is an object that receives requests from a store and translates them into the appropriate action to take against your persistence layer. The persistence layer is usually an HTTP API but may be anything, such as the browser's local storage. Typically the adapter is not invoked directly instead its functionality is accessed through the store.

⚠️ CAUTION you likely want the docs for Adapter as extending this abstract class is unnecessary.

Creating an Adapter

Create a new subclass of Adapter in the app/adapters folder:

app/adapters/application.js
import Adapter from '@ember-data/adapter';

export default Adapter.extend({
  // ...your code here
});

Model-specific adapters can be created by putting your adapter class in an app/adapters/ + model-name + .js file of the application.

app/adapters/post.js
import Adapter from '@ember-data/adapter';

export default Adapter.extend({
  // ...Post-specific adapter code goes here
});

Adapter is an abstract base class that you should override in your application to customize it for your backend. The minimum set of methods that you should implement is:

  • findRecord()
  • createRecord()
  • updateRecord()
  • deleteRecord()
  • findAll()
  • query()

To improve the network performance of your application, you can optimize your adapter by overriding these lower-level methods:

  • findMany()

For an example of the implementation, see RESTAdapter, the included REST adapter.

Show:

By default the store will try to coalesce all findRecord calls within the same runloop into as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call. You can opt out of this behaviour by either not implementing the findMany hook or by setting coalesceFindRequests to false.