What is the difference between Adapter and Fixture Adapter and REST Adapter, and when to use each one?
What is the difference between Adapter and Fixture Adapter and REST Adapter, and when
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
DS.FixtureAdapter(orDS.FixtureAdapter.create()) when you don’t (yet?) care to communicate with a backend, but will store your data as “fixtures” in the client. Once you’ve declared a model:You can define your fixtures:
And then you can use the ember-data methods on them (e.g.
App.Thing.findAll(), etc.) and manipulate them, but of course it will only persist as long as the page does (i.e. the javascript environment).DS.RestAdapter, usable though apparently still under development, was designed to fit well with a Rails API, but could probably be modified / extended to work with whatever RESTful API you’re working with. It knows to processApp.Thing.findAll()by making a call to/things, and to processApp.Thing.find(12)with a call to/things/12. This is a relative path, appended to the namespace parameter you pass in:DS.Adapteris rather abstract: the superclass of the aforementioned built-in Adapters. If neither suit your needs, you may well want to implement your own:Hope that helps. See the readme doc at https://github.com/emberjs/data for more information.