-
-
Notifications
You must be signed in to change notification settings - Fork 869
Conversation
}).then(function(artists) { | ||
return artists.get('firstObject'); | ||
}); | ||
|
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.
whitespace
return this.store.findRecord('post', params.post_id, {include: 'comments,comments.author'}); | ||
} | ||
}); | ||
|
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.
whitespace
``` | ||
The post's comments would then be available in your template as `model.comments`. | ||
|
||
Nested relationships can be specified in the `include` parameter as a dot-separated |
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.
break at period
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.
here I meant not to break at "separated"
The post's comments would then be available in your template as `model.comments`. | ||
|
||
Nested relationships can be specified in the `include` parameter as a dot-separated | ||
sequence of relationship names. So to request both the post's comments and the |
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.
break at period
The value of the parameter should be a comma-separated list of names of the | ||
relationships required. | ||
|
||
If you are using an adapter that supports JSON API, such as Ember's default |
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.
break at comma
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.
Oops.
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.
here I mean to break after the JSONAPIAdapter comma instead of at default
form part of that argument. | ||
For example: | ||
|
||
```js |
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.
javascript
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model: function(params) { |
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.
model(params) {
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.
Will do. I was following examples in the API docs which seem to use the longer form.
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.
The API documentation isn't as evenly updated given its surface. I'll put it in the review queue!
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model: function(params) { |
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.
model(params) {
|
||
```js | ||
// GET to /artists?filter[name]=Adele&include=albums | ||
adele = this.store.query('artist', { |
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.
why isn't this example a model()
hook as well?
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.
The example is contrived of course, but a route targeting a specific record just seemed a little unlikely. But I'm happy to take guidance. If you'd prefer it framed as a model hook I'm happy to do that.
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 disagree, I did that in one of my first Ember apps ;P And I do it in a current app hehe, in an RSVP.hash
. Thank you, the this.store
bit doesn't make sense in a standalone setting, so framing it as a model()
hook seems beneficial.
@MarkMT I think you missed two bits. Nearly there! :) |
I guess I'm confused. The style guide says break at the beginning of every new sentence and |
The value of the parameter should be a comma-separated list of names of the | ||
relationships required. | ||
|
||
If you are using an adapter that supports JSON API, such as Ember's default |
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.
here I mean to break after the JSONAPIAdapter comma instead of at default
``` | ||
The post's comments would then be available in your template as `model.comments`. | ||
|
||
Nested relationships can be specified in the `include` parameter as a dot-separated |
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.
here I meant not to break at "separated"
Ok, hope it's right now. Not sure I understand the requirements, but no problem. Seems to be a lot of inconsistency in the file as a whole. |
Is this good to go now? |
Thanks for your contribution! @homu r+ |
📌 Commit fa38033 has been approved by |
Explain retrieval of related records This commit adds a sub-section to Models: Relationships to explain how to retrieve records from related models using the JSON API 'include' query parameter. This reflects recent changes to the `DS.Store` API documented in emberjs/data#4581
☀️ Test successful - status |
This commit adds a sub-section to Models: Relationships to explain how to retrieve records from related models using the JSON API 'include' query parameter. This reflects recent changes to the
DS.Store
API documented in emberjs/data#4581