Skip to content

Commit

Permalink
Include param should always reference array in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltazore committed Jul 9, 2024
1 parent 3ec0359 commit 61f2d24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions guides/requests/examples/0-basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ import fetch from './fetch';

// ... execute a request
const { content: collection } = await fetch.request(query('company', {
include: 'ceo',
include: ['ceo'],
fields: {
company: 'name',
employee: ['name', 'profileImage']
Expand Down Expand Up @@ -182,7 +182,7 @@ import { query } from '@ember-data/json-api/request';

// ... execute a request
const { content: collection } = await store.request(query('company', {
include: 'ceo',
include: ['ceo'],
fields: {
company: 'name',
employee: ['name', 'profileImage']
Expand Down Expand Up @@ -249,7 +249,7 @@ import fetch from './fetch';
// ... execute a request
try {
const result = await fetch.request(query('company', {
include: 'ceo',
include: ['ceo'],
fields: {
company: 'name',
employee: ['name', 'profileImage']
Expand Down
18 changes: 10 additions & 8 deletions packages/store/src/-private/store-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ export class Store extends BaseClass {
```app/routes/post.js
export default class PostRoute extends Route {
model(params) {
return this.store.findRecord('post', params.post_id, { include: 'comments' });
return this.store.findRecord('post', params.post_id, { include: ['comments'] });
}
}
```
Expand All @@ -1284,15 +1284,17 @@ export class Store extends BaseClass {
In this case, the post's comments would then be available in your template as
`model.comments`.
Multiple relationships can be requested using an `include` parameter consisting of a
comma-separated list (without white-space) while nested relationships can be specified
using a dot-separated sequence of relationship names. So to request both the post's
Multiple relationships can be requested using an `include` parameter consisting
of a list of relationship names, while nested relationships can be specified using a
dot-separated sequence of relationship names. So to request both the post's
comments and the authors of those comments the request would look like this:
```app/routes/post.js
export default class PostRoute extends Route {
model(params) {
return this.store.findRecord('post', params.post_id, { include: 'comments,comments.author' });
return this.store.findRecord('post', params.post_id, {
include: ['comments', 'comments.author']
});
}
}
```
Expand Down Expand Up @@ -1909,19 +1911,19 @@ export class Store extends BaseClass {
```app/routes/posts.js
export default class PostsRoute extends Route {
model() {
return this.store.findAll('post', { include: 'comments' });
return this.store.findAll('post', { include: ['comments'] });
}
}
```
Multiple relationships can be requested using an `include` parameter consisting of a
comma-separated list (without white-space) while nested relationships can be specified
list of relationship names, while nested relationships can be specified
using a dot-separated sequence of relationship names. So to request both the posts'
comments and the authors of those comments the request would look like this:
```app/routes/posts.js
export default class PostsRoute extends Route {
model() {
return this.store.findAll('post', { include: 'comments,comments.author' });
return this.store.findAll('post', { include: ['comments', 'comments.author'] });
}
}
```
Expand Down

0 comments on commit 61f2d24

Please sign in to comment.