docs: general updates and fixes (#13374)
* docs: general updates and fixes * fix lint errors
This commit is contained in:
1 parent
c717535ca2
commit
24199fa47a
25 files changed
+477
-396
No files matched your search
+179
-184
@@ -30887,7 +30887,7 @@ The order’s total amounts are stored in the `OrderSummary`'s `totals` property
|
||||
}
|
||||
```
|
||||
|
||||
To check the outstanding amount of the order, its transaction amounts are summed. Then, the following conditions are checked:
|
||||
To check the outstanding amount of the order, its transaction amounts (from the `Transaction` records) are summed. Then, the following conditions are checked:
|
||||
|
||||
|Condition|Result|
|
||||
|---|---|---|
|
||||
@@ -31344,7 +31344,7 @@ createRemoteLinkStep({
|
||||
|
||||
# Payment Module Options
|
||||
|
||||
In this document, you'll learn about the options of the Payment Module.
|
||||
In this document, you'll learn about the options you can pass to the Payment Module.
|
||||
|
||||
## All Module Options
|
||||
|
||||
@@ -31358,7 +31358,7 @@ In this document, you'll learn about the options of the Payment Module.
|
||||
|
||||
## providers Option
|
||||
|
||||
The `providers` option is an array of payment module providers.
|
||||
The `providers` option is an array of payment module providers to be registered in your Medusa application.
|
||||
|
||||
When the Medusa application starts, these providers are registered and can be used to process payments.
|
||||
|
||||
@@ -31392,10 +31392,12 @@ module.exports = defineConfig({
|
||||
|
||||
The `providers` option is an array of objects that accept the following properties:
|
||||
|
||||
- `resolve`: A string indicating the package name of the module provider or the path to it relative to the `src` directory.
|
||||
- `resolve`: A string indicating the package name of the module provider or the path to it.
|
||||
- `id`: A string indicating the provider's unique name or ID.
|
||||
- `options`: An optional object of the module provider's options.
|
||||
|
||||
Refer to the [Payment Module Providers](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-provider/index.html.md) documentation to learn more.
|
||||
|
||||
|
||||
# Payment Module
|
||||
|
||||
@@ -31604,7 +31606,7 @@ A payment collection stores payment details related to a resource, such as a car
|
||||
|
||||
Every purchase or request for payment starts with a payment collection. The collection holds details necessary to complete the payment, including:
|
||||
|
||||
- The [payment sessions](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-session/index.html.md) that represents the payment amount to authorize.
|
||||
- The [payment sessions](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-session/index.html.md) that represent the payment amount to authorize.
|
||||
- The [payments](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment/index.html.md) that are created when a payment session is authorized. They can be captured and refunded.
|
||||
- The [payment providers](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-provider/index.html.md) that handle the processing of each payment session, including the authorization, capture, and refund.
|
||||
|
||||
@@ -31624,9 +31626,7 @@ You can use this to accept payments in increments or split payments across payme
|
||||
|
||||
The Cart Module provides cart management features. However, it doesn’t provide any features related to accepting payment.
|
||||
|
||||
During checkout, the Medusa application links a cart to a payment collection, which will be used for further payment processing.
|
||||
|
||||
It also implements the payment flow during checkout as explained in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-flow/index.html.md).
|
||||
During checkout, the Medusa application links a cart to a payment collection, which will be used for further payment processing. It also implements the [payment flow](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-flow/index.html.md) during checkout.
|
||||
|
||||

|
||||
|
||||
@@ -32188,13 +32188,13 @@ View the full flow of the webhook event processing in the [processPaymentWorkflo
|
||||
|
||||
# Pricing Concepts
|
||||
|
||||
In this document, you’ll learn about the main concepts in the Pricing Module.
|
||||
In this guide, you’ll learn about the main concepts in the Pricing Module.
|
||||
|
||||
## Price Data Model
|
||||
|
||||
The [Price](https://docs.medusajs.com/references/pricing/models/Price/index.html.md) data model represents a specific price for a resource. For example, the price of a product variant in the USD currency.
|
||||
|
||||
The `Price` data model has an `amount` property that represents the monetary value of the price. It's stored as an integer in base units. For example, `$20.00` is stored as `20`.
|
||||
The `Price` data model has an `amount` property that represents the monetary value of the price. It's stored as an integer in base or major units. For example, `$20.00` is stored as `20`, and `$20.5` is stored as `20.5`.
|
||||
|
||||
The `Price` data model belongs to other data models like `PriceSet` and `PriceList` to provide a variety of pricing features, as explained below.
|
||||
|
||||
@@ -32202,9 +32202,9 @@ The `Price` data model belongs to other data models like `PriceSet` and `PriceLi
|
||||
|
||||
## Price Set
|
||||
|
||||
A [PriceSet](https://docs.medusajs.com/references/pricing/models/PriceSet/index.html.md) represents a collection of prices that are linked to a resource (for example, a product variant or a shipping option).
|
||||
A [PriceSet](https://docs.medusajs.com/references/pricing/models/PriceSet/index.html.md) represents a collection of prices that are linked to a resource. For example, a product variant can have a price set that includes prices in multiple currencies, such as USD and EUR.
|
||||
|
||||
Each of these prices is represented by the [Price data model](https://docs.medusajs.com/references/pricing/models/Price/index.html.md).
|
||||
Each of these prices is represented by the [Price data model](#price-data-model).
|
||||
|
||||

|
||||
|
||||
@@ -32212,11 +32212,13 @@ Each of these prices is represented by the [Price data model](https://docs.medus
|
||||
|
||||
## Price List
|
||||
|
||||
A [PriceList](https://docs.medusajs.com/references/pricing/models/PriceList/index.html.md) is a group of prices only enabled if their conditions and rules are satisfied.
|
||||
A [PriceList](https://docs.medusajs.com/references/pricing/models/PriceList/index.html.md) is a group of prices that are only enabled when their conditions and rules are satisfied. For example, you can apply special prices to customers in the VIP group.
|
||||
|
||||
When the conditions are met, the prices in the price list override the default prices in a price set.
|
||||
|
||||
A price list has optional `start_date` and `end_date` properties that indicate the date range in which a price list can be applied.
|
||||
|
||||
Its associated prices are represented by the `Price` data model.
|
||||
Its associated prices are represented by the [Price data model](#price-data-model).
|
||||
|
||||
|
||||
# Links between Pricing Module and Other Modules
|
||||
@@ -34981,27 +34983,27 @@ Refer to [this reference](https://docs.medusajs.com/references/promotion/interfa
|
||||
|
||||
# Application Method
|
||||
|
||||
In this document, you'll learn what an application method is.
|
||||
In this guide, you'll learn what an application method is in the Promotion Module.
|
||||
|
||||
## What is an Application Method?
|
||||
|
||||
The [ApplicationMethod data model](https://docs.medusajs.com/references/promotion/models/ApplicationMethod/index.html.md) defines how a promotion is applied:
|
||||
The [ApplicationMethod data model](https://docs.medusajs.com/references/promotion/models/ApplicationMethod/index.html.md) defines how a promotion is applied. It has the following properties that determine its behavior:
|
||||
|
||||
|Property|Purpose|
|
||||
|---|---|
|
||||
|\`type\`|Does the promotion discount a fixed amount or a percentage?|
|
||||
|\`target\_type\`|Is the promotion applied on a cart item, shipping method, or the entire order?|
|
||||
|\`allocation\`|Is the discounted amount applied on each item or split between the applicable items?|
|
||||
|Property|Purpose|Possible Values|
|
||||
|---|---|---|
|
||||
|\`type\`|Does the promotion discount a fixed amount or a percentage?|\`fixed\`|
|
||||
|\`target\_type\`|Is the promotion applied to a cart item, shipping method, or the entire order?|\`items\`|
|
||||
|\`allocation\`|Is the discounted amount applied to each item or split between the applicable items?|\`each\`|
|
||||
|
||||
## Target Promotion Rules
|
||||
|
||||
When the promotion is applied to a cart item or a shipping method, you can restrict which items/shipping methods the promotion is applied to.
|
||||
When the promotion is applied to a cart item or a shipping method (in other words, when `target_type` is `items` or `shipping_methods`), you can restrict which items/shipping methods the promotion is applied to.
|
||||
|
||||
The `ApplicationMethod` data model has a collection of `PromotionRule` records to restrict which items or shipping methods the promotion applies to. The `target_rules` property represents this relation.
|
||||
The `ApplicationMethod` data model has a collection of [PromotionRule](https://docs.medusajs.com/references/promotion/models/PromotionRule/index.html.md) records to restrict which items or shipping methods the promotion applies to. The `target_rules` property in the `ApplicationMethod` represents this relation.
|
||||
|
||||

|
||||
|
||||
In this example, the promotion is only applied on products in the cart having the SKU `SHIRT`.
|
||||
In this example, the promotion is only applied to product variants in the cart that have the SKU `SHIRT`.
|
||||
|
||||
***
|
||||
|
||||
@@ -35009,11 +35011,11 @@ In this example, the promotion is only applied on products in the cart having th
|
||||
|
||||
When the promotion’s type is `buyget`, you must specify the “buy X” condition. For example, a cart must have two shirts before the promotion can be applied.
|
||||
|
||||
The application method has a collection of `PromotionRule` items to define the “buy X” rule. The `buy_rules` property represents this relation.
|
||||
The application method has a collection of `PromotionRule` items to define the “buy X” rule. The `buy_rules` property in the `ApplicationMethod` represents this relation.
|
||||
|
||||

|
||||
|
||||
In this example, the cart must have two products with the SKU `SHIRT` for the promotion to be applied.
|
||||
In this example, the cart must have two product variants with the SKU `SHIRT` for the promotion to be applied.
|
||||
|
||||
|
||||
# Campaign
|
||||
@@ -36559,19 +36561,19 @@ Notice that the request object's type is `MedusaStoreRequest` instead of `Medusa
|
||||
|
||||
# Stock Location Concepts
|
||||
|
||||
In this document, you’ll learn about the main concepts in the Stock Location Module.
|
||||
In this guide, you’ll learn about the main concepts in the Stock Location Module.
|
||||
|
||||
## Stock Location
|
||||
|
||||
A stock location, represented by the `StockLocation` data model, represents a location where stock items are kept. For example, a warehouse.
|
||||
A stock location, represented by the [StockLocation data model](https://docs.medusajs.com/references/stock-location-next/models/StockLocation/index.html.md), represents a location where stock items are kept. For example, a warehouse.
|
||||
|
||||
Medusa uses stock locations to provide inventory details, from the Inventory Module, per location.
|
||||
Medusa uses stock locations to provide inventory details, stored and managed by the [Inventory Module](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/inventory/concepts/index.html.md), per location.
|
||||
|
||||
***
|
||||
|
||||
## StockLocationAddress
|
||||
|
||||
The `StockLocationAddress` data model belongs to the `StockLocation` data model. It provides more detailed information of the location, such as country code or street address.
|
||||
The [StockLocationAddress data model](https://docs.medusajs.com/references/stock-location-next/models/StockLocationAddress/index.html.md) belongs to the `StockLocation` data model. It provides more detailed information about the location, such as country code or street address.
|
||||
|
||||
|
||||
# Links between Stock Location Module and Other Modules
|
||||
@@ -37970,7 +37972,7 @@ class ResendNotificationProviderService extends AbstractNotificationProviderServ
|
||||
|
||||
# User Module Options
|
||||
|
||||
In this document, you'll learn about the options of the User Module.
|
||||
In this guide, you'll learn about the options you can pass to the User Module.
|
||||
|
||||
## Module Options
|
||||
|
||||
@@ -37998,7 +38000,7 @@ module.exports = defineConfig({
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Make sure to add the necessary environment variables for the above options in `.env`:
|
||||
Make sure to add the necessary environment variables for the above options to your `.env` file:
|
||||
|
||||
```bash
|
||||
JWT_SECRET=supersecret
|
||||
@@ -43274,56 +43276,26 @@ The following workflows emit this event when they're executed. These workflows a
|
||||
|
||||
# build Command - Medusa CLI Reference
|
||||
|
||||
Create a standalone build of the Medusa application.
|
||||
Create a standalone build of the Medusa application that you can deploy to production.
|
||||
|
||||
This creates a build that:
|
||||
|
||||
- Doesn't rely on the source TypeScript files.
|
||||
- Can be copied to a production server reliably.
|
||||
|
||||
The build is outputted to a new `.medusa/server` directory.
|
||||
The build is output to a new `.medusa/server` directory.
|
||||
|
||||
```bash
|
||||
npx medusa build
|
||||
```
|
||||
|
||||
Refer to [this section](#run-built-medusa-application) for next steps.
|
||||
Refer to the [Build Medusa Application](https://docs.medusajs.com/docs/learn/build/index.html.md) guide for next steps.
|
||||
|
||||
## Options
|
||||
|
||||
|Option|Description|
|
||||
|---|---|---|
|
||||
|\`--admin-only\`|Whether to only build the admin to host it separately. If this option is not passed, the admin is built to the |
|
||||
|
||||
***
|
||||
|
||||
## Run Built Medusa Application
|
||||
|
||||
After running the `build` command, use the following step to run the built Medusa application:
|
||||
|
||||
- Change to the `.medusa/server` directory and install the dependencies:
|
||||
|
||||
```bash npm2yarn
|
||||
cd .medusa/server && npm install
|
||||
```
|
||||
|
||||
- When running the application locally, make sure to copy the `.env` file from the root project's directory. In production, use system environment variables instead.
|
||||
|
||||
```bash npm2yarn
|
||||
cp .env .medusa/server/.env.production
|
||||
```
|
||||
|
||||
- In the system environment variables, set `NODE_ENV` to `production`:
|
||||
|
||||
```bash
|
||||
NODE_ENV=production
|
||||
```
|
||||
|
||||
- Use the `start` command to run the application:
|
||||
|
||||
```bash npm2yarn
|
||||
cd .medusa/server && npm run start
|
||||
```
|
||||
|\`--admin-only\`|Whether to build only the admin to host it separately. If this option is not passed, the admin is built to the |
|
||||
|
||||
***
|
||||
|
||||
@@ -43331,7 +43303,7 @@ cd .medusa/server && npm run start
|
||||
|
||||
By default, the Medusa Admin is built to the `.medusa/server/public/admin` directory.
|
||||
|
||||
If you want a separate build to host the admin standalone, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead.
|
||||
If you want a separate build to host the admin as a standalone application, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead.
|
||||
|
||||
|
||||
# db Commands - Medusa CLI Reference
|
||||
@@ -43456,7 +43428,9 @@ npx medusa db:sync-links
|
||||
|
||||
# develop Command - Medusa CLI Reference
|
||||
|
||||
Start Medusa application in development. This command watches files for any changes, then rebuilds the files and restarts the Medusa application.
|
||||
Start the Medusa application in development.
|
||||
|
||||
This command watches files for any changes, then rebuilds the files and restarts the Medusa application.
|
||||
|
||||
```bash
|
||||
npx medusa develop
|
||||
@@ -43466,8 +43440,8 @@ npx medusa develop
|
||||
|
||||
|Option|Description|Default|
|
||||
|---|---|---|---|---|
|
||||
|\`-H \<host>\`|Set host of the Medusa server.|\`localhost\`|
|
||||
|\`-p \<port>\`|Set port of the Medusa server.|\`9000\`|
|
||||
|\`-H \<host>\`|Set the host of the Medusa server.|\`localhost\`|
|
||||
|\`-p \<port>\`|Set the port of the Medusa server.|\`9000\`|
|
||||
|
||||
|
||||
# exec Command - Medusa CLI Reference
|
||||
@@ -43623,9 +43597,25 @@ npx medusa user --email <email> [--password <password>]
|
||||
|---|---|---|---|---|---|---|
|
||||
|\`-e \<email>\`|The user's email.|Yes|-|
|
||||
|\`-p \<password>\`|The user's password.|No|-|
|
||||
|\`-i \<id>\`|The user's ID.|No|An automatically generated ID.|
|
||||
|\`--invite\`|Whether to create an invite instead of a user. When using this option, you don't need to specify a password.
|
||||
If ran successfully, you'll receive the invite token in the output.|No|\`false\`|
|
||||
|\`-i \<id>\`|The user's ID.|No|An automatically generated ID is used.|
|
||||
|\`--invite\`|Whether to create a user invite instead of directly creating a user. Learn more in the |No|\`false\`|
|
||||
|
||||
***
|
||||
|
||||
## Create User Invite with Medusa CLI
|
||||
|
||||
The `user` command accepts the `--invite` option to create a user invite. The user must accept the invite before they can log into the Medusa Admin.
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
npx medusa user --email user@example.com --invite
|
||||
```
|
||||
|
||||
The command will create a user invite and output the invite token. You can then either:
|
||||
|
||||
- Accept the invite in the Medusa Admin at the path `/app/invite?token=<invite_token>`
|
||||
- Accept the invite using the [Accept Invite API route](https://docs.medusajs.com/api/admin#invites_postinvitesaccept).
|
||||
|
||||
|
||||
# Medusa CLI Reference
|
||||
@@ -43653,56 +43643,26 @@ npx medusa --help
|
||||
|
||||
# build Command - Medusa CLI Reference
|
||||
|
||||
Create a standalone build of the Medusa application.
|
||||
Create a standalone build of the Medusa application that you can deploy to production.
|
||||
|
||||
This creates a build that:
|
||||
|
||||
- Doesn't rely on the source TypeScript files.
|
||||
- Can be copied to a production server reliably.
|
||||
|
||||
The build is outputted to a new `.medusa/server` directory.
|
||||
The build is output to a new `.medusa/server` directory.
|
||||
|
||||
```bash
|
||||
npx medusa build
|
||||
```
|
||||
|
||||
Refer to [this section](#run-built-medusa-application) for next steps.
|
||||
Refer to the [Build Medusa Application](https://docs.medusajs.com/docs/learn/build/index.html.md) guide for next steps.
|
||||
|
||||
## Options
|
||||
|
||||
|Option|Description|
|
||||
|---|---|---|
|
||||
|\`--admin-only\`|Whether to only build the admin to host it separately. If this option is not passed, the admin is built to the |
|
||||
|
||||
***
|
||||
|
||||
## Run Built Medusa Application
|
||||
|
||||
After running the `build` command, use the following step to run the built Medusa application:
|
||||
|
||||
- Change to the `.medusa/server` directory and install the dependencies:
|
||||
|
||||
```bash npm2yarn
|
||||
cd .medusa/server && npm install
|
||||
```
|
||||
|
||||
- When running the application locally, make sure to copy the `.env` file from the root project's directory. In production, use system environment variables instead.
|
||||
|
||||
```bash npm2yarn
|
||||
cp .env .medusa/server/.env.production
|
||||
```
|
||||
|
||||
- In the system environment variables, set `NODE_ENV` to `production`:
|
||||
|
||||
```bash
|
||||
NODE_ENV=production
|
||||
```
|
||||
|
||||
- Use the `start` command to run the application:
|
||||
|
||||
```bash npm2yarn
|
||||
cd .medusa/server && npm run start
|
||||
```
|
||||
|\`--admin-only\`|Whether to build only the admin to host it separately. If this option is not passed, the admin is built to the |
|
||||
|
||||
***
|
||||
|
||||
@@ -43710,7 +43670,7 @@ cd .medusa/server && npm run start
|
||||
|
||||
By default, the Medusa Admin is built to the `.medusa/server/public/admin` directory.
|
||||
|
||||
If you want a separate build to host the admin standalone, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead.
|
||||
If you want a separate build to host the admin as a standalone application, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead.
|
||||
|
||||
|
||||
# db Commands - Medusa CLI Reference
|
||||
@@ -43835,7 +43795,9 @@ npx medusa db:sync-links
|
||||
|
||||
# develop Command - Medusa CLI Reference
|
||||
|
||||
Start Medusa application in development. This command watches files for any changes, then rebuilds the files and restarts the Medusa application.
|
||||
Start the Medusa application in development.
|
||||
|
||||
This command watches files for any changes, then rebuilds the files and restarts the Medusa application.
|
||||
|
||||
```bash
|
||||
npx medusa develop
|
||||
@@ -43845,8 +43807,8 @@ npx medusa develop
|
||||
|
||||
|Option|Description|Default|
|
||||
|---|---|---|---|---|
|
||||
|\`-H \<host>\`|Set host of the Medusa server.|\`localhost\`|
|
||||
|\`-p \<port>\`|Set port of the Medusa server.|\`9000\`|
|
||||
|\`-H \<host>\`|Set the host of the Medusa server.|\`localhost\`|
|
||||
|\`-p \<port>\`|Set the port of the Medusa server.|\`9000\`|
|
||||
|
||||
|
||||
# exec Command - Medusa CLI Reference
|
||||
@@ -44002,9 +43964,25 @@ npx medusa user --email <email> [--password <password>]
|
||||
|---|---|---|---|---|---|---|
|
||||
|\`-e \<email>\`|The user's email.|Yes|-|
|
||||
|\`-p \<password>\`|The user's password.|No|-|
|
||||
|\`-i \<id>\`|The user's ID.|No|An automatically generated ID.|
|
||||
|\`--invite\`|Whether to create an invite instead of a user. When using this option, you don't need to specify a password.
|
||||
If ran successfully, you'll receive the invite token in the output.|No|\`false\`|
|
||||
|\`-i \<id>\`|The user's ID.|No|An automatically generated ID is used.|
|
||||
|\`--invite\`|Whether to create a user invite instead of directly creating a user. Learn more in the |No|\`false\`|
|
||||
|
||||
***
|
||||
|
||||
## Create User Invite with Medusa CLI
|
||||
|
||||
The `user` command accepts the `--invite` option to create a user invite. The user must accept the invite before they can log into the Medusa Admin.
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
npx medusa user --email user@example.com --invite
|
||||
```
|
||||
|
||||
The command will create a user invite and output the invite token. You can then either:
|
||||
|
||||
- Accept the invite in the Medusa Admin at the path `/app/invite?token=<invite_token>`
|
||||
- Accept the invite using the [Accept Invite API route](https://docs.medusajs.com/api/admin#invites_postinvitesaccept).
|
||||
|
||||
|
||||
# Medusa CLI Reference
|
||||
@@ -93713,7 +93691,9 @@ These components allow you to use common Medusa Admin components in your custom
|
||||
|
||||
# create Method - Service Factory Reference
|
||||
|
||||
This method creates one or more records of the data model.
|
||||
This method of a module's service creates one or more records of a data model.
|
||||
|
||||
The method's name is of the format `createDataModel`, where `DataModel` is the plural pascal-case name of the data model.
|
||||
|
||||
## Create One Record
|
||||
|
||||
@@ -93727,7 +93707,7 @@ const post = await postModuleService.createPosts({
|
||||
})
|
||||
```
|
||||
|
||||
If an object is passed of the method, an object of the created record is also returned.
|
||||
If an object is passed to the method, the created record object is returned.
|
||||
|
||||
***
|
||||
|
||||
@@ -93746,12 +93726,14 @@ const posts = await postModuleService.createPosts([
|
||||
])
|
||||
```
|
||||
|
||||
If an array is passed of the method, an array of the created records is also returned.
|
||||
If an array of objects is passed to the method, an array containing the created records is returned.
|
||||
|
||||
|
||||
# delete Method - Service Factory Reference
|
||||
|
||||
This method deletes one or more records.
|
||||
This method of a module's service deletes one or more records.
|
||||
|
||||
The method's name is `deleteDataModel`, where `DataModel` is the plural pascal-case name of the data model.
|
||||
|
||||
## Delete One Record
|
||||
|
||||
@@ -93759,7 +93741,7 @@ This method deletes one or more records.
|
||||
await postModuleService.deletePosts("123")
|
||||
```
|
||||
|
||||
To delete one record, pass its ID as a parameter of the method.
|
||||
To delete one record, pass its ID as a parameter to the method.
|
||||
|
||||
***
|
||||
|
||||
@@ -93772,7 +93754,7 @@ await postModuleService.deletePosts([
|
||||
])
|
||||
```
|
||||
|
||||
To delete multiple records, pass an array of IDs as a parameter of the method.
|
||||
To delete multiple records, pass an array of IDs as a parameter to the method.
|
||||
|
||||
***
|
||||
|
||||
@@ -93784,14 +93766,16 @@ await postModuleService.deletePosts({
|
||||
})
|
||||
```
|
||||
|
||||
To delete records matching a set of filters, pass an object of filters as a parameter.
|
||||
To delete records matching a set of filters, pass an object of filters as a parameter to the method.
|
||||
|
||||
Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
|
||||
Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples.
|
||||
|
||||
|
||||
# list Method - Service Factory Reference
|
||||
|
||||
This method retrieves a list of records.
|
||||
This method of a module's service retrieves a list of records.
|
||||
|
||||
The method's name is `listDataModel`, where `DataModel` is the plural pascal-case name of the data model.
|
||||
|
||||
## Retrieve List of Records
|
||||
|
||||
@@ -93813,9 +93797,9 @@ const posts = await postModuleService.listPosts({
|
||||
|
||||
### Parameters
|
||||
|
||||
To retrieve records matching a set of filters, pass an object of the filters as a first parameter.
|
||||
To retrieve records matching a set of filters, pass an object of the filters as the first parameter.
|
||||
|
||||
Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
|
||||
Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -93835,7 +93819,7 @@ const posts = await postModuleService.listPosts({}, {
|
||||
|
||||
### Parameters
|
||||
|
||||
To retrieve records with their relations, pass as a second parameter an object having a `relations` property. `relations`'s value is an array of relation names.
|
||||
To retrieve records with their relations, pass an object with a `relations` property as the second parameter. `relations`'s value is an array of relation names.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -93853,7 +93837,7 @@ const posts = await postModuleService.listPosts({}, {
|
||||
|
||||
### Parameters
|
||||
|
||||
By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property.
|
||||
By default, retrieved records have all their properties. To select specific properties to retrieve, pass a `select` property in the second object parameter.
|
||||
|
||||
`select`'s value is an array of property names to retrieve.
|
||||
|
||||
@@ -93863,7 +93847,7 @@ The method returns an array of the first `15` records matching the filters.
|
||||
|
||||
***
|
||||
|
||||
## Paginate Relations
|
||||
## Paginate Records
|
||||
|
||||
```ts
|
||||
const posts = await postModuleService.listPosts({}, {
|
||||
@@ -93897,7 +93881,7 @@ const posts = await postModuleService.listPosts({}, {
|
||||
|
||||
### Parameters
|
||||
|
||||
To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be:
|
||||
To sort records by one or more properties, pass an `order` property in the second object parameter. Its value is an object whose keys are the property names, and values can either be:
|
||||
|
||||
- `ASC` to sort by this property in the ascending order.
|
||||
- `DESC` to sort by this property in the descending order.
|
||||
@@ -93909,7 +93893,9 @@ The method returns an array of the first `15` records matching the filters.
|
||||
|
||||
# listAndCount Method - Service Factory Reference
|
||||
|
||||
This method retrieves a list of records with the total count.
|
||||
This method of a module's service retrieves a list of records with the total count.
|
||||
|
||||
The method's name is `listAndCountDataModel`, where `DataModel` is the plural pascal-case name of the data model.
|
||||
|
||||
## Retrieve List of Records
|
||||
|
||||
@@ -93934,9 +93920,9 @@ const [posts, count] = await postModuleService.listAndCountPosts({
|
||||
|
||||
### Parameters
|
||||
|
||||
To retrieve records matching a set of filters, pass an object of the filters as a first parameter.
|
||||
To retrieve records matching a set of filters, pass an object of the filters as the first parameter.
|
||||
|
||||
Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
|
||||
Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -93959,7 +93945,7 @@ const [posts, count] = await postModuleService.listAndCountPosts({}, {
|
||||
|
||||
### Parameters
|
||||
|
||||
To retrieve records with their relations, pass as a second parameter an object having a `relations` property. Its value is an array of relation names.
|
||||
To retrieve records with their relations, pass an object with a `relations` property as the second parameter. Its value is an array of relation names.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -93980,7 +93966,7 @@ const [posts, count] = await postModuleService.listAndCountPosts({}, {
|
||||
|
||||
### Parameters
|
||||
|
||||
By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property.
|
||||
By default, retrieved records have all their properties. To select specific properties to retrieve, pass a `select` property in the second object parameter.
|
||||
|
||||
`select`'s value is an array of property names to retrieve.
|
||||
|
||||
@@ -93993,7 +93979,7 @@ The method returns an array with two items:
|
||||
|
||||
***
|
||||
|
||||
## Paginate Relations
|
||||
## Paginate Records
|
||||
|
||||
```ts
|
||||
const [posts, count] = await postModuleService.listAndCountPosts({}, {
|
||||
@@ -94030,7 +94016,7 @@ const [posts, count] = await postModuleService.listAndCountPosts({}, {
|
||||
|
||||
### Parameters
|
||||
|
||||
To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be:
|
||||
To sort records by one or more properties, pass an `order` property in the second object parameter. Its value is an object whose keys are the property names, and values can either be:
|
||||
|
||||
- `ASC` to sort by this property in the ascending order.
|
||||
- `DESC` to sort by this property in the descending order.
|
||||
@@ -94045,7 +94031,9 @@ The method returns an array with two items:
|
||||
|
||||
# restore Method - Service Factory Reference
|
||||
|
||||
This method restores one or more records of the data model that were [soft-deleted](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/methods/soft-delete/index.html.md).
|
||||
This method of a module's service restores one or more records of a data model that were [soft-deleted](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/methods/soft-delete/index.html.md).
|
||||
|
||||
The method's name is of the format `restoreDataModel`, where `DataModel` is the plural pascal-case name of the data model.
|
||||
|
||||
## Restore One Record
|
||||
|
||||
@@ -94055,7 +94043,7 @@ const restoredPosts = await postModuleService.restorePosts("123")
|
||||
|
||||
### Parameters
|
||||
|
||||
To restore one record, pass its ID as a parameter of the method.
|
||||
To restore one record, pass its ID as a parameter to the method.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -94063,9 +94051,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod
|
||||
|
||||
For example, the returned object of the above example is:
|
||||
|
||||
```ts
|
||||
restoredPosts = {
|
||||
post_id: ["123"],
|
||||
```json
|
||||
{
|
||||
"post_id": ["123"],
|
||||
}
|
||||
```
|
||||
|
||||
@@ -94082,7 +94070,7 @@ const restoredPosts = await postModuleService.restorePosts([
|
||||
|
||||
### Parameters
|
||||
|
||||
To restore multiple records, pass an array of IDs as a parameter of the method.
|
||||
To restore multiple records, pass an array of IDs as a parameter to the method.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -94090,9 +94078,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod
|
||||
|
||||
For example, the returned object of the above example is:
|
||||
|
||||
```ts
|
||||
restoredPosts = {
|
||||
post_id: [
|
||||
```json
|
||||
{
|
||||
"post_id": [
|
||||
"123",
|
||||
"321",
|
||||
],
|
||||
@@ -94111,9 +94099,9 @@ const restoredPosts = await postModuleService.restorePosts({
|
||||
|
||||
### Parameters
|
||||
|
||||
To restore records matching a set of filters, pass an object of fitlers as a parameter of the method.
|
||||
To restore records matching a set of filters, pass an object of filters as a parameter to the method.
|
||||
|
||||
Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
|
||||
Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -94121,9 +94109,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod
|
||||
|
||||
For example, the returned object of the above example is:
|
||||
|
||||
```ts
|
||||
restoredPosts = {
|
||||
post_id: [
|
||||
```json
|
||||
{
|
||||
"post_id": [
|
||||
"123",
|
||||
],
|
||||
}
|
||||
@@ -94132,7 +94120,9 @@ restoredPosts = {
|
||||
|
||||
# retrieve Method - Service Factory Reference
|
||||
|
||||
This method retrieves one record of the data model by its ID.
|
||||
This method retrieves one record of a data model by its ID.
|
||||
|
||||
The method's name is `retrieveDataModel`, where `DataModel` is the singular pascal-case name of the data model.
|
||||
|
||||
## Retrieve a Record
|
||||
|
||||
@@ -94162,7 +94152,7 @@ const post = await postModuleService.retrievePost("123", {
|
||||
|
||||
### Parameters
|
||||
|
||||
To retrieve the data model with relations, pass as a second parameter of the method an object with the property `relations`. `relations`'s value is an array of relation names.
|
||||
To retrieve the data model with relations, pass an object with the property `relations` as the second parameter. `relations`'s value is an array of relation names.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -94180,7 +94170,7 @@ const post = await postModuleService.retrievePost("123", {
|
||||
|
||||
### Parameters
|
||||
|
||||
By default, all of the record's properties are retrieved. To select specific ones, pass in the second object parameter a `select` property. Its value is an array of property names.
|
||||
By default, all of the record's properties are retrieved. To select specific ones, pass a `select` property in the second object parameter. Its value is an array of property names.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -94189,7 +94179,9 @@ The method returns the record as an object.
|
||||
|
||||
# softDelete Method - Service Factory Reference
|
||||
|
||||
This method soft deletes one or more records of the data model.
|
||||
This method of a module's service soft deletes one or more records of a data model.
|
||||
|
||||
The method's name is of the format `softDeleteDataModel`, where `DataModel` is the plural pascal-case name of the data model.
|
||||
|
||||
## Soft Delete One Record
|
||||
|
||||
@@ -94201,7 +94193,7 @@ const deletedPosts = await postModuleService.softDeletePosts(
|
||||
|
||||
### Parameters
|
||||
|
||||
To soft delete a record, pass its ID as a parameter of the method.
|
||||
To soft delete a record, pass its ID as a parameter to the method.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -94210,8 +94202,8 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod
|
||||
For example, the returned object of the above example is:
|
||||
|
||||
```ts
|
||||
deletedPosts = {
|
||||
post_id: ["123"],
|
||||
{
|
||||
"post_id": ["123"],
|
||||
}
|
||||
```
|
||||
|
||||
@@ -94228,7 +94220,7 @@ const deletedPosts = await postModuleService.softDeletePosts([
|
||||
|
||||
### Parameters
|
||||
|
||||
To soft delete multiple records, pass an array of IDs as a parameter of the method.
|
||||
To soft delete multiple records, pass an array of IDs as a parameter to the method.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -94237,8 +94229,8 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod
|
||||
For example, the returned object of the above example is:
|
||||
|
||||
```ts
|
||||
deletedPosts = {
|
||||
post_id: [
|
||||
{
|
||||
"post_id": [
|
||||
"123",
|
||||
"321",
|
||||
],
|
||||
@@ -94257,9 +94249,9 @@ const deletedPosts = await postModuleService.softDeletePosts({
|
||||
|
||||
### Parameters
|
||||
|
||||
To soft delete records matching a set of filters, pass an object of filters as a parameter.
|
||||
To soft delete records matching a set of filters, pass an object of filters as a parameter to the method.
|
||||
|
||||
Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
|
||||
Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -94268,15 +94260,17 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod
|
||||
For example, the returned object of the above example is:
|
||||
|
||||
```ts
|
||||
deletedPosts = {
|
||||
post_id: ["123"],
|
||||
{
|
||||
"post_id": ["123"],
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
# update Method - Service Factory Reference
|
||||
|
||||
This method updates one or more records of the data model.
|
||||
This method of a module's service updates one or more records.
|
||||
|
||||
The method's name is `updateDataModel`, where `DataModel` is the plural pascal-case name of the data model.
|
||||
|
||||
## Update One Record
|
||||
|
||||
@@ -94289,7 +94283,7 @@ const post = await postModuleService.updatePosts({
|
||||
|
||||
### Parameters
|
||||
|
||||
To update one record, pass an object that at least has an `id` property, identifying the ID of the record to update.
|
||||
To update one record, pass an object that has at least an `id` property, identifying the ID of the record to update.
|
||||
|
||||
You can pass in the same object any other properties to update.
|
||||
|
||||
@@ -94316,13 +94310,13 @@ const posts = await postModuleService.updatePosts([
|
||||
|
||||
### Parameters
|
||||
|
||||
To update multiple records, pass an array of objects. Each object has at least an `id` property, identifying the ID of the record to update.
|
||||
To update multiple records, pass an array of objects. Each object must have at least an `id` property, identifying the ID of the record to update.
|
||||
|
||||
You can pass in each object any other properties to update.
|
||||
|
||||
### Returns
|
||||
|
||||
The method returns an array of objects of updated records.
|
||||
The method returns an array of updated record objects.
|
||||
|
||||
***
|
||||
|
||||
@@ -94341,18 +94335,18 @@ const posts = await postModuleService.updatePosts({
|
||||
|
||||
### Parameters
|
||||
|
||||
To update records that match specified filters, pass as a parameter an object having two properties:
|
||||
To update records that match specified filters, pass an object with two properties as a parameter:
|
||||
|
||||
- `selector`: An object of filters that a record must match to be updated.
|
||||
- `data`: An object of the properties to update in every record that match the filters in `selector`.
|
||||
|
||||
In the example above, you update the `published_at` property of every post record whose name is `My Post`.
|
||||
|
||||
Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
|
||||
Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples.
|
||||
|
||||
### Returns
|
||||
|
||||
The method returns an array of objects of updated records.
|
||||
The method returns an array of updated record objects.
|
||||
|
||||
***
|
||||
|
||||
@@ -94390,17 +94384,17 @@ To update records matching different sets of filters, pass an array of objects,
|
||||
|
||||
In the example above, you update the `published_at` property of post records whose name is `My Post`, and update the `metadata` property of post records whose name is `Another Post`.
|
||||
|
||||
Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
|
||||
Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples.
|
||||
|
||||
### Returns
|
||||
|
||||
The method returns an array of objects of updated records.
|
||||
The method returns an array of updated record objects.
|
||||
|
||||
***
|
||||
|
||||
## Update a JSON Property
|
||||
|
||||
```ts
|
||||
```ts highlights={highlights}
|
||||
const post = await postModuleService.updatePosts({
|
||||
id: "123",
|
||||
name: "My Post",
|
||||
@@ -94411,13 +94405,14 @@ const post = await postModuleService.updatePosts({
|
||||
})
|
||||
```
|
||||
|
||||
When you have a JSON property in your data model, you can update it by adding, updating, or removing properties within that JSON object. Medusa will merge the properties you pass in the `update` method with the existing JSON object.
|
||||
When you have a [JSON property](https://docs.medusajs.com/docs/learn/fundamentals/data-models/json-properties/index.html.md) in your data model, you can update it by adding, updating, or removing properties within that JSON object. Medusa will merge the properties you pass in the `update` method with the existing JSON object.
|
||||
|
||||
### Remove a Property from the JSON Property
|
||||
|
||||
```ts
|
||||
```ts highlights={highlights}
|
||||
const post = await postModuleService.updatePosts({
|
||||
id: "123",
|
||||
name: "My Post",
|
||||
metadata: {
|
||||
is_featured: "",
|
||||
},
|
||||
@@ -94441,22 +94436,22 @@ Refer to the [Service Factory](https://docs.medusajs.com/docs/learn/fundamentals
|
||||
|
||||
When your module's main service extends the service factory, Medusa will:
|
||||
|
||||
1. Generate data-management methods in your main service for each of the data models passed to the `MedusaService` function.
|
||||
2. Generate internal services for each of the data models passed to the `MedusaService` function, which can be resolved in loaders.
|
||||
1. Generate [data-management methods in your main service](#main-service-methods) for each of the data models passed to the `MedusaService` function.
|
||||
2. Generate [internal services](#internal-generated-service-methods) for each of the data models passed to the `MedusaService` function, which can be resolved in loaders.
|
||||
|
||||
### Main Service Methods
|
||||
|
||||
The names of the generated methods for a service extending the service factory are of the format `{operationName}_{dataModelName}`, where:
|
||||
The names of the generated methods for a service extending the service factory are of the format `{operationName}{DataModelName}`, where:
|
||||
|
||||
- `{operationName}` is the name of the operation. For example, `create`.
|
||||
- `{dataModelName}` is the pascal-case version of the data model's key that's passed in the object parameter of `MedusaService`. The name is pluralized for all operations except the `retrieve` operation.
|
||||
- `{DataModelName}` is the pascal-case version of the data model's key that's passed in the object parameter of `MedusaService`. The name is pluralized for all operations except the `retrieve` operation.
|
||||
|
||||
Some examples of method names:
|
||||
|
||||
- `createPosts`
|
||||
- `createMyPosts`
|
||||
- `retrievePost`
|
||||
- `listPosts`
|
||||
- `createPosts` (`Post` data model)
|
||||
- `createMyPosts` (`MyPost` data model)
|
||||
- `retrievePost` (`Post` data model)
|
||||
- `listPosts` (`Post` data model)
|
||||
|
||||
### Internal Generated Service Methods
|
||||
|
||||
|
||||
Reference in new issue
Block a user