fix: skip non-existent collection

This commit is contained in:
chenos 2021-02-18 12:15:09 +08:00
parent df2137da79
commit 5000affc26
2 changed files with 6 additions and 0 deletions

View File

@ -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 });

View File

@ -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) => {