JavaScript Hooks (mb_hooks)
Place *.js files in ./mb_hooks (override with --hooksDir) to hook into record lifecycle events using the embedded Goja JS runtime.
onRecordBeforeCreate("posts", (e) => { if (!e.record.slug && e.record.title) { e.record.slug = e.record.title.toLowerCase().replace(/\s+/g, "-"); }});
onRecordAfterCreate("orders", (e) => { $log.info("Order created", { id: e.record.id });});- Supported lifecycle hooks:
onRecordBeforeCreate,onRecordAfterCreate,onRecordBeforeUpdate,onRecordAfterUpdate,onRecordBeforeDelete,onRecordAfterDelete. - Throwing an error inside a
Before*hook aborts the mutation and returns an API error to the caller.