docs: general updates and fixes (#13374)
* docs: general updates and fixes * fix lint errors
This commit is contained in:
@@ -760,9 +760,9 @@ Now that you've created the collections, you need to add them to Payload's confi
|
||||
In `src/payload.config.ts`, add the following imports at the top of the file:
|
||||
|
||||
```ts title="src/payload.config.ts" badgeLabel="Storefront" badgeColor="blue"
|
||||
import { Users } from './collections/Users'
|
||||
import { Products } from './collections/Products'
|
||||
import { Media } from './collections/Media'
|
||||
import { Users } from "./collections/Users"
|
||||
import { Products } from "./collections/Products"
|
||||
import { Media } from "./collections/Media"
|
||||
```
|
||||
|
||||
Then, add the collections to the `collections` array of the `buildConfig` function:
|
||||
@@ -2626,9 +2626,9 @@ The `updatePayloadItemsStep` will update an item in a Payload collection, such a
|
||||
To create the step, create the file `src/workflows/steps/update-payload-items.ts` with the following content:
|
||||
|
||||
```ts title="src/workflows/steps/update-payload-items.ts" badgeLabel="Medusa application" badgeColor="green"
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk";
|
||||
import { PayloadItemResult, PayloadUpsertData } from "../../modules/payload/types";
|
||||
import { PAYLOAD_MODULE } from "../../modules/payload";
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import { PayloadItemResult, PayloadUpsertData } from "../../modules/payload/types"
|
||||
import { PAYLOAD_MODULE } from "../../modules/payload"
|
||||
|
||||
type StepInput = {
|
||||
collection: string;
|
||||
@@ -2639,20 +2639,20 @@ export const updatePayloadItemsStep = createStep(
|
||||
"update-payload-items",
|
||||
async ({ items, collection }: StepInput, { container }) => {
|
||||
const payloadModuleService = container.resolve(PAYLOAD_MODULE)
|
||||
const ids: string[] = items.map(item => item.id);
|
||||
const ids: string[] = items.map((item) => item.id)
|
||||
|
||||
const prevData = await payloadModuleService.find(collection, {
|
||||
where: {
|
||||
id: {
|
||||
in: ids.join(",")
|
||||
}
|
||||
}
|
||||
in: ids.join(","),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const updatedItems: PayloadItemResult[] = []
|
||||
|
||||
for (const item of items) {
|
||||
const { id, ...data } = item;
|
||||
const { id, ...data } = item
|
||||
updatedItems.push(
|
||||
await payloadModuleService.update(
|
||||
collection,
|
||||
@@ -2660,16 +2660,16 @@ export const updatePayloadItemsStep = createStep(
|
||||
{
|
||||
where: {
|
||||
id: {
|
||||
equals: id
|
||||
}
|
||||
}
|
||||
equals: id,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return new StepResponse({
|
||||
items: updatedItems.map(item => item.doc)
|
||||
items: updatedItems.map((item) => item.doc),
|
||||
}, {
|
||||
prevData,
|
||||
collection,
|
||||
@@ -2677,11 +2677,11 @@ export const updatePayloadItemsStep = createStep(
|
||||
},
|
||||
async (data, { container }) => {
|
||||
if (!data) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
const { prevData, collection } = data;
|
||||
const { prevData, collection } = data
|
||||
|
||||
const payloadModuleService = container.resolve(PAYLOAD_MODULE);
|
||||
const payloadModuleService = container.resolve(PAYLOAD_MODULE)
|
||||
|
||||
await Promise.all(
|
||||
prevData.docs.map(async ({
|
||||
@@ -2694,9 +2694,9 @@ export const updatePayloadItemsStep = createStep(
|
||||
{
|
||||
where: {
|
||||
id: {
|
||||
equals: id
|
||||
}
|
||||
}
|
||||
equals: id,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user