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.

5458 questions
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
23
votes
13 answers

How to manually set an object state to clean (saved) using ember-data

Explanation: I'm using ember-data for a project of mine and I have a question that revolves around the possibility of dirtying an object and then setting its state to clean again on purpose - without commiting the changes. The scenario is this: Say…
Kasper Tidemann
  • 478
  • 1
  • 3
  • 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
  • 8,754
  • 9
  • 52
  • 115
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,448
  • 13
  • 16
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
  • 681
  • 1
  • 7
  • 20
20
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,192
  • 2
  • 28
  • 42
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
  • 13,582
  • 14
  • 46
  • 73
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,755
  • 3
  • 19
  • 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,715
  • 39
  • 150
  • 262
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,634
  • 3
  • 25
  • 44
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
  • 21,477
  • 48
  • 188
  • 367
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,208
  • 4
  • 14
  • 25
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,054
  • 1
  • 20
  • 47
18
votes
2 answers

Socket.IO with Ember and Ember-Data

I've been poking around and I can't find any up to date examples of ember (1.0.0-rc.1) and ember-data(revision 11) that also use socket.io. I've tried something like this. App.ApplicationRoute = Ember.Route.extend({ setupController:…
Chad
  • 16,774
  • 8
  • 29
  • 41