fix: req.collection being lost when querying a global inside a collection (#5727)

This commit is contained in:
Paul
2024-04-08 15:16:37 -03:00
committed by GitHub
parent cf135fd1e4
commit cbd03ed2f8
2 changed files with 7 additions and 3 deletions

View File

@@ -2,6 +2,8 @@
import type { CollectionConfig } from '../../../../packages/payload/src/collections/config/types'
import { dataHooksGlobalSlug } from '../../globals/Data'
export const dataHooksSlug = 'data-hooks'
export const DataHooks: CollectionConfig = {
@@ -22,9 +24,11 @@ export const DataHooks: CollectionConfig = {
],
beforeChange: [
({ context, data, collection }) => {
async ({ req, context, data, collection }) => {
context['collection_beforeChange_collection'] = JSON.stringify(collection)
await req.payload.findGlobal({
slug: dataHooksGlobalSlug,
})
return data
},
],