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