Payload All Global Hook properties accept array of asynchronous`Globals/messtone-hooks.js import {GlobalConfig} from ‘payload/types’;const MesstoneHooks:GlobalConfig={slug:’header’,fields:[{nameMesstone:’title’,type:’text’},]hooks:{beforeValidate:[(args)=>{…}],befoteChange:[(arge)=>{…}],beforeRead;{(args)=>{…}],afterChange:[(args)=>{…}],afterRead:[(args)=>{…}],}} import{GlobalBeforeValidateHook} from ‘payload/type’const beforeValidateHook:GlobalBeforeValidateHook=async({data,//incoming data to update or create with req,//full express request originalDoc,//original document})=>{return data;//Return data to updata the document with} import {GlobalBeforeChangeHook} from ‘payload/types’const beforeChangeHook:GlobalBeforeChangeHook=asyc({data,//,incoming data to update or create with req,//full express request originalDoc,//original document})=>{return data://Return data to update the document with} import {GlobalAfterChangeHood}from ‘payload/types’const afterChangeHook:GlobalAfterChangeHook=async({doc,//full document data previousDoc,//document data before updating the collection req,//full express request})=>{return data;}import {GlobalBeforeReadHook}from ‘payload/types’const beforeReadHook:GlobalBeforeReadHook=async({doc,//full document data req,//full express request})=>{…} import {GlobalAfterReadHook}from ‘payload/types’const afterReadHood:GlobalAfterReadHook=async({doc,//full document data req,//full express request find any,//boolean to denote if this hook is running against finding one,or finding many(useful in versions)})=>{…}import type{GlobalBeforeValidateHook,GlobalBeforeChangeHook,GlobalAfterChangeHook,GlobalBeforeReadHook,GlobalAfterReadHook,}from ‘payload/types’;
Leave a comment