docs: fixes to read-only links + add examples for filtering by relations (#13218)
This commit is contained in:
1 parent
12a38bcd2b
commit
14de565077
8 files changed
+305
-130
No files matched your search
@@ -826,7 +826,7 @@ Next, use that token to register the customer:
|
||||
curl -X POST 'http://localhost:9000/store/customers' \
|
||||
--header 'Content-Type: application/json' \
|
||||
-H 'x-publishable-api-key: {api_key}' \
|
||||
--header 'Authorization Bearer {token}' \
|
||||
--header 'Authorization: Bearer {token}' \
|
||||
--data-raw '{
|
||||
"email": "customer@gmail.com"
|
||||
}'
|
||||
|
||||
@@ -137,6 +137,56 @@ const posts = await postModuleService.listPosts({
|
||||
|
||||
In the example above, only posts that have a publish date are retrieved.
|
||||
|
||||
--
|
||||
|
||||
## Filter by Relation's Property
|
||||
|
||||
Consider that your module also has an `Author` data model, and the `Post` data model has a relation to the `Author` data model.
|
||||
|
||||
To filter posts by a property of the `Author` data model, you can use nested objects.
|
||||
|
||||
For example:
|
||||
|
||||
```ts
|
||||
const posts = await postModuleService.listPosts({
|
||||
author: {
|
||||
name: "John",
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
In the example above, you retrieve posts whose `author` relation has a `name` property equal to `John`.
|
||||
|
||||
### Filter by Relation's Property Not Equal
|
||||
|
||||
```ts
|
||||
const posts = await postModuleService.listPosts({
|
||||
author: {
|
||||
name: {
|
||||
$or: [
|
||||
{
|
||||
name: {
|
||||
$eq: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: {
|
||||
$ne: "John",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
When you need to filter by a relationship property whose value doesn't match a specific condition, you must use an `$or` operator that applies the following conditions:
|
||||
|
||||
1. The relationship's property is not set. This is necessary to exclude posts that don't have an author.
|
||||
2. The relationship's property is not equal to the specific value.
|
||||
|
||||
So, in the example above, you retrieve posts either not having an author or having an author whose name is not "John".
|
||||
|
||||
---
|
||||
|
||||
## Apply Range Filters
|
||||
@@ -442,14 +492,6 @@ The following operators are supported by the service factory filtering mechanism
|
||||
Joins two or more conditions with a logical OR.
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>
|
||||
`$not`
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
Inverts the logic of a condition. For example, `$not: { $eq: value }` matches any value that is not equal to the specified value.
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
</Table.Body>
|
||||
</Table>
|
||||
|
||||
@@ -300,10 +300,10 @@ In this example, you receive the `token` and `email` from the page's query param
|
||||
|
||||
Then, when the form that has the password field is submitted, you send a request to the [Reset Password API route](!api!/store#auth_postactor_typeauth_providerupdate), passing it the token, email, and new password.
|
||||
|
||||
Notice that the JS SDK passes the token in the `Authorization Bearer` header. So, if you're implementing this flow without using the JS SDK, make sure to pass the token accordingly.
|
||||
Notice that the JS SDK passes the token in the `Authorization: Bearer` header. So, if you're implementing this flow without using the JS SDK, make sure to pass the token accordingly.
|
||||
|
||||
<Note>
|
||||
|
||||
Before [Medusa v2.6](https://github.com/medusajs/medusa/releases/tag/v2.6), you passed the token as a query parameter. Now, you must pass it in the `Authorization Bearer` header.
|
||||
Before [Medusa v2.6](https://github.com/medusajs/medusa/releases/tag/v2.6), you passed the token as a query parameter. Now, you must pass it in the `Authorization: Bearer` header.
|
||||
|
||||
</Note>
|
||||
Reference in new issue
Block a user