From fce545bed67ab810de37da96ed8d6f6991a55560 Mon Sep 17 00:00:00 2001 From: James Mikrut Date: Mon, 24 Jun 2024 14:10:00 -0400 Subject: [PATCH] Update overview.mdx --- docs/local-api/overview.mdx | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/docs/local-api/overview.mdx b/docs/local-api/overview.mdx index b33ee497e..225cda6c5 100644 --- a/docs/local-api/overview.mdx +++ b/docs/local-api/overview.mdx @@ -28,31 +28,7 @@ You can gain access to the currently running `payload` object via two ways: #### Accessing from args or `req` -<<<<<<< HEAD In most places within Payload itself, you can access `payload` directly from the arguments of hooks, access control, validation functions, and similar. This is the simplest way to access Payload in most cases. Most config functions take the `req` (Request) object, which has Payload bound to it (`req.payload`). -======= -You can import or require `payload` into your own files after it's been initialized, but you need to make sure that -your `import` / `require` statements come **after** you call `payload.init()`—otherwise Payload won't have been -initialized yet. That might be obvious. To us, it's usually not. - -Example: - -```ts -import payload from 'payload' -import { CollectionAfterChangeHook } from 'payload/types' - -const afterChangeHook: CollectionAfterChangeHook = async () => { - const posts = await payload.find({ - collection: 'posts', - }) -} -``` - -#### Accessing from the `req` - -Payload is available anywhere you have access to the `req` - including within your access control and hook -functions. ->>>>>>> e782d9942928c97c3ff567fc311c7d889f8b06d3 Example: