diff --git a/packages/plugin-automations/src/models/automation-job.ts b/packages/plugin-automations/src/models/automation-job.ts index ab1934af8..bca105afd 100644 --- a/packages/plugin-automations/src/models/automation-job.ts +++ b/packages/plugin-automations/src/models/automation-job.ts @@ -54,6 +54,9 @@ export class AutomationJobModel extends Model { const jobType = this.get('type'); const collectionName = this.get('collection_name'); const M = this.database.getModel(collectionName); + if (!collectionName || !M) { + return; + } let filter: any = this.toFilter(result); let data: any = this.toValues(result); const { where = {} } = M.parseApiJson({ filter }); diff --git a/packages/plugin-automations/src/models/automation.ts b/packages/plugin-automations/src/models/automation.ts index 8fc84ef88..72d3e8003 100644 --- a/packages/plugin-automations/src/models/automation.ts +++ b/packages/plugin-automations/src/models/automation.ts @@ -82,6 +82,9 @@ export class AutomationModel extends Model { const changedFields = (this.get('changed') as any) || []; const M = this.database.getModel(collectionName); const automationType = this.get('type'); + if (automationType !== 'schedule' || !collectionName || !M) { + return; + } switch (automationType) { case 'collections:afterCreate': M.addHook('afterCreate', hookName, async (model, options) => {