docs: explicit payload usage from req to avoid import payload confusion (#10291)
This commit is contained in:
@@ -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: {
|
||||||
|
|||||||
Reference in New Issue
Block a user