From 61f2d24005f24f1310da29aca7f48ef73c9c369e Mon Sep 17 00:00:00 2001 From: Kirill Shaplyko Date: Tue, 9 Jul 2024 11:16:22 +0200 Subject: [PATCH] Include param should always reference array in docs --- guides/requests/examples/0-basic-usage.md | 6 +++--- packages/store/src/-private/store-service.ts | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/guides/requests/examples/0-basic-usage.md b/guides/requests/examples/0-basic-usage.md index 4119e2bf934..412d9a15833 100644 --- a/guides/requests/examples/0-basic-usage.md +++ b/guides/requests/examples/0-basic-usage.md @@ -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'] @@ -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'] @@ -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'] diff --git a/packages/store/src/-private/store-service.ts b/packages/store/src/-private/store-service.ts index c2d922bac49..bc9a1c5a8df 100644 --- a/packages/store/src/-private/store-service.ts +++ b/packages/store/src/-private/store-service.ts @@ -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'] }); } } ``` @@ -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'] + }); } } ``` @@ -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'] }); } } ```