kfir124
kfir124

Reputation: 1306

Ember-data Why does it need to know which attrs will i use?

Can't Ember-data just see the JSON response it gets and understand by it which attributes are used by the server?
For example if the response for 'GET /api/user/1' is like:

{
    id: 1,
    first_name: 'Miki',
    last_name: 'Coco',
    age: 17
}

Its pretty obvious that the user model has just first_name, last_name and age.

Why would i need to configure it?

Upvotes: 1

Views: 41

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

Here's the things that I can think of off the top of my head.

  1. Change management (isDirty)
  2. Serialization/deserialization of different types
  3. You can put other properties on the model that won't necessarily be sent back to the server on save etc
  4. Relationship handling

Honestly, I avoid Ember Data for simple models that I don't need CRUD for, it's overkill (unless I'm worried about client side caching etc)

Upvotes: 1

Related Questions