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

Include param should always reference array in docs #9507

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1278,7 +1278,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 @@ -1305,15 +1305,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 @@ -1930,19 +1932,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
Loading