-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[DOC release] Update documentation for store #3794
Conversation
* `id` - mandatory, unique record's key | ||
* `type` - mandatory string which matches `model` name (can be singular or plural form) | ||
* `attributes` - object which holds data for record attributes - `DS.attr`'s declared in model | ||
* `relationships` - object which must contain any of the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you mention that links
, data
and meta
are supposed to be under each relationships' respective key, to remove confusion.
Nice PR @kuzirashi, thanks! Left a couple of comments for minor tweaks. |
Thanks for awesome feedback. What do you think now? @wecc |
@@ -58,12 +58,12 @@ var dasherize = Ember.String.dasherize; | |||
"data": [ | |||
{ | |||
"id": "3", | |||
"type": "players" | |||
"type": "player" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the JSONAPISerializer
expects types to be plural.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store.push expects singular, JSON API serializer expects plural? I thought it is unified. Should I revert changes to json-api-serializer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bmac is correct. The internal Ember Data JSON API format differs a bit from the one used by JSONAPISerializer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is confusing, at least to me. Shouldn't this be mentioned somewhere, somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ED uses camelCased attributes and singular types internally, regardless of what adapter/serializer you're using.
When you're using the JSON API adapter/serializer we want users to be able to use the examples available on jsonapi.org and have it just work. Most users never have to care about the internal format since the serializer handles the work for them.
This is documented in the guides, http://guides.emberjs.com/v2.0.0/models/pushing-records-into-the-store/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should document this difference in some other places. Not everyone reads the guides.
This looks great @kuzirashi. Excited to see this merged. |
Changes applied. |
Its possible to embed an ember-twiddles via iframe in the docs by just inlining the html. However, they are discouraged because they are slow to load, are not very PR friendly and in general lead to some extra overhead in managing them which makes it harder to notice when iframe content is out of date. |
I think this pr looks good. @kuzirashi do you mind squashing your commits into 1 and prepending the commit message with |
Done. @bmac |
[DOC release] Update documentation for store
Great work @kuzirashi! |
Thanks @kuzirashi. |
This attempts to resolve #3687 and update other parts of store docs to mention JSONAPI move of ED. It's currently a massive WIP, but I'm open to all feedback.