Questions tagged [ember-data]

ember-data is a data persistence extension for the Ember.js framework.

Because the MVC framework builds applications which run in the browser rather than returning fully-rendered pages in response to browser requests, it requires a method for saving and reloading user data.

Ember.js supports a number of "data persistence" libraries, including a data store component inherited from the framework. In general these frameworks support CRUD operations on a RESTful web service, and as such they are agnostic regarding the technology of the back-end web service.

Ember-data is the "official" data persistence library for Ember.js, supported by the Ember.js team. It uses "adapters" to load data for use by Ember.js applications, and allows developers to write custom adapters to support their own specific data store.

Beta Period

During the beta period (up until 1.0) the API is constantly changing, you can keep up to date by reading the Transition Document.

Getting help

Ember-data is supported in much the same way as Ember.js itself.

The Stack Overflow tag is actively monitored by several contributors to Ember. You may try asking questions in the active IRC channel #emberjs on irc.freenode.net. Other resources can found on the Ember.js community page

Technical questions that are accompanied by working code make it easier for other to help give good answers. JSFiddle | JSBin

To report bugs against Ember.js, or to propose new functionality, create an issue on the Github project.

5483 questions
23
votes
1 answer

Handling errors with the (now default) Ember Data JSON-API adapter

I am using Ember 1.13.7 and Ember Data 1.13.8, which by default use the JSON-API standard to format the payloads sent to and received from the API. I would like to use Ember Data's built-in error handling in order to display red "error" form fields…
danr1979
  • 461
  • 1
  • 3
  • 10
23
votes
3 answers

Accessing meta information passed in a json server response

I am using the Ember-Data Rest-Adapter and the JSON returned from my server looks basically like the one in the Active Model Serializers Documentation { "meta": { "total": 10 }, "posts": [ { "title": "Post 1", "body": "Hello!" }, {…
Michael Klein
  • 785
  • 6
  • 14
22
votes
3 answers

Ember.js sorting and filtering children of a hasMany relationship in parent route

Update #2 I found that when I refactored the filtering logic to take place in a compound computed property within the PostController instead of within individual routes, I was able to get it working. The solution was ultimately dependent upon a…
Bryan Langslet
  • 292
  • 2
  • 10
22
votes
2 answers

Can I define a default value for ember-data model attributes?

When I define an attribute for a model in ember-data, can I specify a default value? The ember-data model definition suggests attributes are defined like this: attributeName: DS.attr('number') ...with an optional second argument as an options hash.…
pjmorse
  • 9,204
  • 9
  • 54
  • 124
21
votes
3 answers

Get belongsTo ID without fetching record

I'm trying to fetch the belongsTo ID without fetching the actual record. My JSON API returns the ID for the belongsTo relation. I have the following models App.Recipe = DS.Model.extend( title: DS.attr() ingredients: DS.hasMany('ingredient',…
Martin
  • 2,302
  • 2
  • 30
  • 42
21
votes
4 answers

What can you do with Ember Data Models when in the error state?

I'm struggling to understand the workflow that would be used in the following scenario: A user creates a model, let's call it Product. We present them with a form to fill in. The save errors for some reason other than validations (timeout, access…
David Monagle
  • 1,701
  • 16
  • 19
20
votes
3 answers

Dynamically add js object to model array in 1.13

I have the following code: var msg = this.store.createRecord({text:'first title', createdAt: "2015-06-22T20:06:06+03:00" }) this.get('model.content').pushObject(msg); msg.save(); We create new record. Then push in it to the model to display. It…
Alex Berdyshev
  • 761
  • 2
  • 7
  • 21
20
votes
1 answer

Using DS.model or Ember.model or Ember.Object when defining a model?

This screencast : http://www.embercasts.com/episodes/getting-started-with-ember-model used Ember.model to create a person model like this: App.Person = Ember.Model.extend({ name : Ember.attr() }) The docs give this example using…
Jatin
  • 14,112
  • 16
  • 49
  • 78
20
votes
2 answers

Ember-Data .find() vs .all() - how to control cache?

I was told that in order to not make a request all the time, one can use .all() method to load data that is kept in the store. But how does Ember deal with cache? I have a couple of questions. How do you control cache? When do you use .find() and…
wryrych
  • 1,765
  • 4
  • 20
  • 31
20
votes
4 answers

What is the best way to modify the date format when ember-data does serialization?

In my ember-data adapter I use this line to serialize my model var data = record.serialize(); But I've noticed my models with a date type ... App.Foo = DS.Model.extend({ start: DS.attr('date') }); ... will post the date like this to my REST…
Toran Billups
  • 27,111
  • 40
  • 155
  • 268
19
votes
3 answers

Ember.js array as model's property

Cheers! I have some model, and one attribute of it is an array, but for some reasons (I use mongoDB on the server and it's problem with embedded models and ember-data) I can't do somthing like this: App.Foo = DS.Model.extend({ ... numbers:…
xamenrax
  • 1,724
  • 3
  • 27
  • 47
19
votes
1 answer

Correct clean up code

I have the following two routes for edit and new: WZ.ExercisesNewRoute = Em.Route.extend model: -> WZ.Exercise.createRecord() deactivate: -> @_super.apply this, arguments …
dagda1
  • 26,856
  • 59
  • 237
  • 450
18
votes
1 answer

Ember-data embedded records current state?

I am really stuck with tons of problems caused by Ember-data and it lacks of embedded records support. I have searched the entire web, most of the posts are outdated others are outdated + requires me to use 3rd party libraries or to wire up 300…
kfir124
  • 1,286
  • 4
  • 14
  • 27
18
votes
1 answer

performing rollback on model with hasMany relation

I have models defined as : App.Answer = DS.Model.extend({ name: DS.attr('string'), layoutName: DS.attr('string') }); App.Question = DS.Model.extend({ name: DS.attr('string'), answers: DS.hasMany('answer', {async: true}) }); I have…
Deewendra Shrestha
  • 2,313
  • 1
  • 23
  • 53
18
votes
2 answers

What's the proper way to access parameters from within Ember.Route. setupController?

Ember.Route.model has access to the params variable, but Ember.Route.setupController does not. This is troublesome for me, because my path has multiple dynamic segments, and I need to use all of them in my template. Specifically, my path looks like…
NudeCanalTroll
  • 2,266
  • 2
  • 19
  • 43