Skip to content

Defines a callback to be executed on specific CMS operations CmsTrigger

Example

typescript
const trigger = new CmsTrigger('insert-one', (context) => {
  console.log('New CMS document inserted:', context.queryResult);
  // Perform additional actions after CMS document insertion.
});

// Use the trigger in RestOptions
const { app } = await createRest({
  authTriggers: [trigger],
  // ... other options
});

Extends

Constructors

Constructor

new CmsTrigger(operation, callback?): CmsTrigger

Creates a new CmsTrigger instance

Example

typescript
// Log all CMS updates
const updateTrigger = new CmsTrigger('update-one', (context) => {
  console.log('CMS document updated:', context.queryResult);
});

// Track CMS document removals
const removeTrigger = new CmsTrigger('remove-one', (context) => {
  console.log('CMS document removed:', context.queryResult);
});

Parameters

ParameterTypeDescription
operationCmsOperationThe CMS operation to trigger on
callback?(context) => voidThe callback function to execute

Returns

CmsTrigger

Overrides

DatabaseTrigger.constructor

Properties

PropertyTypeDescriptionInherited from
callback(context) => voidThe callback function to be executedDatabaseTrigger.callback
operationDatabaseOperationThe CMS operation that triggers the callbackDatabaseTrigger.operation

Methods

applyToSchema()

applyToSchema(schema): void

Applies the trigger to a Mongoose schema

Parameters

ParameterTypeDescription
schemaanyThe mongoose schema to apply the trigger to

Returns

void

Inherited from

DatabaseTrigger.applyToSchema