You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`.*` means that all of data model's properties should be retrieved. You can also retrieve specific properties by replacing the `*` with the property name, for each property.
130
+
`.*` means that all of the data model's properties should be retrieved. You can also retrieve specific properties by replacing the `*` with the property name for each property.
131
131
132
132
For example:
133
133
@@ -166,7 +166,7 @@ In the example above, you retrieve all products linked to a post.
166
166
167
167
### Apply Filters and Pagination on Linked Records
168
168
169
-
Consider you want to apply filters or pagination configurations on the product(s) linked to `post`. To do that, you must query the module link's table instead.
169
+
Consider that you want to apply filters or pagination configurations on the product(s) linked to a`post`. To do that, you must query the module link's table instead.
170
170
171
171
As mentioned in the [Module Link](../page.mdx) documentation, Medusa creates a table for your module link. So, not only can you retrieve linked records, but you can also retrieve the records in a module link's table.
- You pass the `entryPoint` property of the link definition as the value for `entity`. So, Query will retrieve records from the module link's table.
202
-
- You pass three items to the `field` property:
202
+
- You pass three items to the `fields` property:
203
203
-`*` to retrieve the link table's fields. This is useful if the link table has [custom columns](../custom-columns/page.mdx).
204
204
-`product.*` to retrieve the fields of a product record linked to a `Post` record.
205
205
-`post.*` to retrieve the fields of a `Post` record linked to a product record.
@@ -272,7 +272,7 @@ Under the hood, Query uses one of the following methods from the data model's mo
272
272
-`listX` if you don't pass [pagination parameters](#apply-pagination). For example, `listPosts`.
273
273
-`listAndCountX` if you pass pagination parameters. For example, `listAndCountPosts`.
274
274
275
-
Both methods accepts a filter object that can be used to filter records.
275
+
Both methods accept a filter object that can be used to filter records.
276
276
277
277
Those filters don't just allow you to filter by exact values. You can also filter by properties that don't match a value, match multiple values, and other filter types.
278
278
@@ -497,7 +497,7 @@ In the example above, you retrieve only deleted posts by enabling the `withDelet
497
497
498
498
## Configure Query to Throw Errors
499
499
500
-
By default, if Query doesn't find records matching your query, it returns an empty array. You can add option to configure Query to throw an error when no records are found.
500
+
By default, if Query doesn't find records matching your query, it returns an empty array. You can add an option to configure Query to throw an error when no records are found.
501
501
502
502
The `query.graph` method accepts as a second parameter an object that can have a `throwIfKeyNotFound` property. Its value is a boolean indicating whether to throw an error if no record is found when filtering by IDs. By default, it's `false`.
In the example above, Query throws an error either if no post is found with the ID `post_123` or if its found but its author ID isn't `author_123`.
539
+
In the example above, Query throws an error either if no post is found with the ID `post_123` or if it's found but its author ID isn't `author_123`.
540
540
541
541
In the above example, it's assumed that a post belongs to an author, so it has an `author_id` property. However, this also works in the opposite case, where an author has many posts.
542
542
@@ -615,7 +615,7 @@ The `validateAndTransformQuery` accepts two parameters:
615
615
4.`order`: The fields to order the returned items by in ascending or descending order.
616
616
2. A Query configuration object. It accepts the following properties:
617
617
1.`defaults`: An array of default fields and relations to retrieve in each resource.
618
-
2.`isList`: A boolean indicating whether a list of items are returned in the response.
618
+
2.`isList`: A boolean indicating whether a list of items is returned in the response.
619
619
3.`allowed`: An array of fields and relations allowed to be passed in the `fields` query parameter.
620
620
4.`defaultLimit`: A number indicating the default limit to use if no limit is provided. By default, it's `50`.
621
621
@@ -631,7 +631,7 @@ As of [Medusa v2.2.0](https://github.com/medusajs/medusa/releases/tag/v2.2.0), `
631
631
632
632
</Note>
633
633
634
-
For example, Create the file `src/api/customs/route.ts` with the following content:
634
+
For example, create the file `src/api/customs/route.ts` with the following content:
635
635
636
636
exportconst queryConfigHighlights = [
637
637
["17", "req.queryConfig", "Pass the parsed request Query configurations to the Query graph execution."]
@@ -667,7 +667,7 @@ In the API route, you pass `req.queryConfig` to `query.graph`. `queryConfig` has
667
667
668
668
### Test it Out
669
669
670
-
To test it out, start your Medusa application and send a `GET` request to the `/customs` API route. A list of records are retrieved with the specified fields in the middleware.
670
+
To test it out, start your Medusa application and send a `GET` request to the `/customs` API route. A list of records is retrieved with the specified fields in the middleware.
671
671
672
672
```json title="Returned Data"
673
673
{
@@ -684,6 +684,6 @@ Try passing one of the Query configuration parameters, like `fields` or `limit`,
684
684
685
685
<Note>
686
686
687
-
Learn more about [specifing fields and relations](!api!/store#select-fields-and-relations) and [pagination](!api!/store#pagination) in the API reference.
687
+
Learn more about [specifying fields and relations](!api!/store#select-fields-and-relations) and [pagination](!api!/store#pagination) in the API reference.
`.*` means that all of data model's properties should be retrieved. You can also retrieve specific properties by replacing the `*` with the property name, for each property.
12240
+
`.*` means that all of the data model's properties should be retrieved. You can also retrieve specific properties by replacing the `*` with the property name for each property.
12241
12241
12242
12242
For example:
12243
12243
@@ -12276,7 +12276,7 @@ In the example above, you retrieve all products linked to a post.
12276
12276
12277
12277
### Apply Filters and Pagination on Linked Records
12278
12278
12279
-
Consider you want to apply filters or pagination configurations on the product(s) linked to `post`. To do that, you must query the module link's table instead.
12279
+
Consider that you want to apply filters or pagination configurations on the product(s) linked to a `post`. To do that, you must query the module link's table instead.
12280
12280
12281
12281
As mentioned in the [Module Link](https://docs.medusajs.com/learn/fundamentals/module-links/index.html.md) documentation, Medusa creates a table for your module link. So, not only can you retrieve linked records, but you can also retrieve the records in a module link's table.
- You pass the `entryPoint` property of the link definition as the value for `entity`. So, Query will retrieve records from the module link's table.
12305
-
- You pass three items to the `field` property:
12305
+
- You pass three items to the `fields` property:
12306
12306
- `*` to retrieve the link table's fields. This is useful if the link table has [custom columns](https://docs.medusajs.com/learn/fundamentals/module-links/custom-columns/index.html.md).
12307
12307
- `product.*` to retrieve the fields of a product record linked to a `Post` record.
12308
12308
- `post.*` to retrieve the fields of a `Post` record linked to a product record.
@@ -12371,7 +12371,7 @@ Under the hood, Query uses one of the following methods from the data model's mo
12371
12371
- `listX` if you don't pass [pagination parameters](#apply-pagination). For example, `listPosts`.
12372
12372
- `listAndCountX` if you pass pagination parameters. For example, `listAndCountPosts`.
12373
12373
12374
-
Both methods accepts a filter object that can be used to filter records.
12374
+
Both methods accept a filter object that can be used to filter records.
12375
12375
12376
12376
Those filters don't just allow you to filter by exact values. You can also filter by properties that don't match a value, match multiple values, and other filter types.
12377
12377
@@ -12565,7 +12565,7 @@ In the example above, you retrieve only deleted posts by enabling the `withDelet
12565
12565
12566
12566
## Configure Query to Throw Errors
12567
12567
12568
-
By default, if Query doesn't find records matching your query, it returns an empty array. You can add option to configure Query to throw an error when no records are found.
12568
+
By default, if Query doesn't find records matching your query, it returns an empty array. You can add an option to configure Query to throw an error when no records are found.
12569
12569
12570
12570
The `query.graph` method accepts as a second parameter an object that can have a `throwIfKeyNotFound` property. Its value is a boolean indicating whether to throw an error if no record is found when filtering by IDs. By default, it's `false`.
In the example above, Query throws an error either if no post is found with the ID `post_123` or if its found but its author ID isn't `author_123`.
12607
+
In the example above, Query throws an error either if no post is found with the ID `post_123` or if it's found but its author ID isn't `author_123`.
12608
12608
12609
12609
In the above example, it's assumed that a post belongs to an author, so it has an `author_id` property. However, this also works in the opposite case, where an author has many posts.
12610
12610
@@ -12683,7 +12683,7 @@ The `validateAndTransformQuery` accepts two parameters:
12683
12683
4. `order`: The fields to order the returned items by in ascending or descending order.
12684
12684
2. A Query configuration object. It accepts the following properties:
12685
12685
1. `defaults`: An array of default fields and relations to retrieve in each resource.
12686
-
2. `isList`: A boolean indicating whether a list of items are returned in the response.
12686
+
2. `isList`: A boolean indicating whether a list of items is returned in the response.
12687
12687
3. `allowed`: An array of fields and relations allowed to be passed in the `fields` query parameter.
12688
12688
4. `defaultLimit`: A number indicating the default limit to use if no limit is provided. By default, it's `50`.
12689
12689
@@ -12695,7 +12695,7 @@ The middleware transforms these parameters to configurations that you can pass t
12695
12695
12696
12696
As of [Medusa v2.2.0](https://github.com/medusajs/medusa/releases/tag/v2.2.0), `remoteQueryConfig` has been deprecated in favor of `queryConfig`. Their usage is still the same, only the property name has changed.
12697
12697
12698
-
For example, Create the file `src/api/customs/route.ts` with the following content:
12698
+
For example, create the file `src/api/customs/route.ts` with the following content:
12699
12699
12700
12700
```ts title="src/api/customs/route.ts"
12701
12701
import {
@@ -12727,7 +12727,7 @@ In the API route, you pass `req.queryConfig` to `query.graph`. `queryConfig` has
12727
12727
12728
12728
### Test it Out
12729
12729
12730
-
To test it out, start your Medusa application and send a `GET` request to the `/customs` API route. A list of records are retrieved with the specified fields in the middleware.
12730
+
To test it out, start your Medusa application and send a `GET` request to the `/customs` API route. A list of records is retrieved with the specified fields in the middleware.
12731
12731
12732
12732
```json title="Returned Data"
12733
12733
{
@@ -12742,7 +12742,7 @@ To test it out, start your Medusa application and send a `GET` request to the `/
12742
12742
12743
12743
Try passing one of the Query configuration parameters, like `fields` or `limit`, and you'll see its impact on the returned result.
12744
12744
12745
-
Learn more about [specifing fields and relations](https://docs.medusajs.com/api/store#select-fields-and-relations) and [pagination](https://docs.medusajs.com/api/store#pagination) in the API reference.
12745
+
Learn more about [specifying fields and relations](https://docs.medusajs.com/api/store#select-fields-and-relations) and [pagination](https://docs.medusajs.com/api/store#pagination) in the API reference.
0 commit comments