docs: explicit payload usage from req to avoid import payload confusion (#10291)

This commit is contained in:
Sasha
2025-01-01 03:49:20 +02:00
committed by GitHub
parent f3f36d8010
commit 76e44024cc

View File

@@ -72,8 +72,8 @@ const Customer: CollectionConfig = {
slug: 'customers', slug: 'customers',
hooks: { hooks: {
afterChange: [ afterChange: [
async ({ doc }) => { async ({ doc, req }) => {
await payload.update({ await req.payload.update({
// DANGER: updating the same slug as the collection in an afterChange will create an infinite loop! // DANGER: updating the same slug as the collection in an afterChange will create an infinite loop!
collection: 'customers', collection: 'customers',
id: doc.id, id: doc.id,
@@ -101,12 +101,12 @@ const MyCollection: CollectionConfig = {
slug: 'slug', slug: 'slug',
hooks: { hooks: {
afterChange: [ afterChange: [
async ({ context, doc }) => { async ({ context, doc, req }) => {
// return if flag was previously set // return if flag was previously set
if (context.triggerAfterChange === false) { if (context.triggerAfterChange === false) {
return return
} }
await payload.update({ await req.payload.update({
collection: contextHooksSlug, collection: contextHooksSlug,
id: doc.id, id: doc.id,
data: { data: {