Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Ember Data

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

UPDATE customers SET salesperson = "Mike" WHERE state = "NH"

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

ActiveRecord

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

$.getJSON('/posts/1', function(data) { controller.set('content', data); });

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Ember Data

Slide 14

Slide 14 text

DS.Store Application Semantics Server Semantics translates DS.Adapter

Slide 15

Slide 15 text

DS.Adapter DS.Serializer

Slide 16

Slide 16 text

DS.Adapter DS.Serializer • Are relationships saved in the parent or the child? • What payloads are sent to what URLs? • What actions map to what HTTP verbs? • What is the name of the primary key? • What are the names of attributes? • Are objects embedded or referred to by ID?

Slide 17

Slide 17 text

What's Next?

Slide 18

Slide 18 text

Full Time!

Slide 19

Slide 19 text

Bug Fixes!

Slide 20

Slide 20 text

Per-Type Adapters

Slide 21

Slide 21 text

Server Team

Slide 22

Slide 22 text

find: function(store, type, id) { if (type === App.Post) { $.ajax('/enterprise_cms/v134uu5/ db-legacy/posts_endpoint-v2/'+id, 'GET', { success: function(json) { store.load(type, json); } }); } else if (type === App.Comment) { $.ajax('/comments/'+id, 'GET', { success: function(json) { store.load(type, json); } }); } }

Slide 23

Slide 23 text

DS.Store.registerAdapter('App.Post', DS.Adapter.extend({ find: function(store, type, id) { $.ajax(this.buildURL(type), 'GET', { success: function(json) { store.load(type, json); } }); } }));

Slide 24

Slide 24 text

Helps you isolate crazy.

Slide 25

Slide 25 text

Read-Only Records

Slide 26

Slide 26 text

App.Serializer = DS.Serializer.extend({ optionsForMaterializedAttribute: function(type, attributeName) { if (attributeName === 'updatedAt') { return { readOnly: true }; } } });

Slide 27

Slide 27 text

App.Serializer = DS.Serializer.extend({ materializeOptions: function(record, hash) { if (hash.read_only === true) { record.materializeOptions({ readOnly: true }); } } });

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

DS.RESTAdapter.map('App.Tweet', { updatedAt: { readOnly: true, keyName: 'last_date' } });

Slide 30

Slide 30 text

DS.RESTAdapter.configure('App.Tweet', { readOnly: true });

Slide 31

Slide 31 text

Embedded Data

Slide 32

Slide 32 text

// GET /comments/789 { "comment": { "id": 789, "title": "Browser question", "body": "the question, \"What browser am I using, and why does it matter?\"", "user": { "firstName": "Jeff", "lastName": "Chang" } } }

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

// PUT /comments/789 { "comment": { "id": 789, "title": "Browser questions", "body": "the question, \"What browser am I using, and why does it matter?\"" } } // PUT /users/123 { "user": { "id": 123, "firstName": "Jeffrey", "lastName": "Chang" } } Embedded Loading

Slide 35

Slide 35 text

DS.RESTAdapter.map('App.Comment', { user: { embedded: "load" } }); Embedded Loading

Slide 36

Slide 36 text

// PUT /comments/789 { "comment": { "id": 789, "title": "Browser questions", "body": "the question, \"What browser am I using, and why does it matter?\"", "user": { "firstName": "Jeffrey", "lastName": "Chang" } } } Embedded

Slide 37

Slide 37 text

DS.RESTAdapter.map('App.Comment', { user: { embedded: "always" } }); Embedded

Slide 38

Slide 38 text

github.com/ emberjs/data

Slide 39

Slide 39 text

Alpha!

Slide 40

Slide 40 text

Thank you. Questions? http://plus.tomdale.net http://emberjs.com