Skip to content

r.hook(...)

r.hook(type, target, fn, options?) — attaches a lifecycle hook (validation, preSave, postSave, preDelete, postDelete, preQuery, postQuery) to one or more target handlers, or — for postSave/preDelete/postDelete/postQuery — to { allOf: entityRef } (“every write/query handler of this entity”, replacing the old r.entityHook(type, entity, fn)). Post-hooks accept a phase option; preDelete always runs in-transaction — it guards the delete. The hook body is an opaque code span.


From packages/framework/src/engine/feature-ast/patterns.ts -> HookPattern