Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all store.push(type, data) calls with store.push(data) calls #42

Open
igorT opened this issue Jun 13, 2015 · 6 comments
Open

Replace all store.push(type, data) calls with store.push(data) calls #42

igorT opened this issue Jun 13, 2015 · 6 comments

Comments

@igorT
Copy link

igorT commented Jun 13, 2015

Ember data has all the necessary helpers that do this, just need to use those and notice where store.push is used. Will need to parse DS.Model definitions for it to work though

@Serabe
Copy link
Contributor

Serabe commented Jul 10, 2015

Can you please provide more info on dropping the type argument?

@knownasilya
Copy link
Collaborator

@Serabe since push now takes a JSON API object, which has all the relevant data, so the type has become redundant. See the blog post: http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_internal-format-change-to-json-api

@Serabe
Copy link
Contributor

Serabe commented Jul 10, 2015

Thank you, @knownasilya. Then, one conversion would be:

store.push('post', {
  id: 'my-post',
  title: 'Post title',
  author: 'knownasilya',
  comments: [
    { id: 'first', type: 'comment'},
    { id: 'second', type: 'pingback'},
  ],
});

to:

store.push({
  id: 'my-post',
  type: 'post',
  data: {
    attributes: {
      title: 'Post title',
    },
    relationships: {
      author: {
        data: {id: 'knownasilya', type: 'user'},
      },
      comments: {
        data: [
          {id: 'first', type: 'comment'},
          {id: 'second', type: 'pingback'},
        ]
      }
    }
  }
});

Wouldn't it?

Note: The json was written by hand directly in the comment textarea, there might be some unbalance [, { or (.

P.S. Just so nobody gets nervous reading this, ), }, ]. xkcd

@abuiles
Copy link
Owner

abuiles commented Jul 13, 2015

We might also need support for store.find, store.all, store.getById

@Serabe
Copy link
Contributor

Serabe commented Jul 13, 2015

@abuiles I don't see how those methods change after JSONAPI.

@igorT
Copy link
Author

igorT commented Jul 25, 2015

agreed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants