From 4e19571c0823217d012327295db0272fe672f77a Mon Sep 17 00:00:00 2001 From: Junyi Date: Sun, 5 Jun 2022 21:58:06 +0800 Subject: [PATCH] fix(plugin-workflow): fix collection trigger transaction (#474) --- packages/plugins/workflow/src/triggers/collection.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/plugins/workflow/src/triggers/collection.ts b/packages/plugins/workflow/src/triggers/collection.ts index b9b17dac75..1b5a4cd1d6 100644 --- a/packages/plugins/workflow/src/triggers/collection.ts +++ b/packages/plugins/workflow/src/triggers/collection.ts @@ -39,13 +39,15 @@ async function handler(this: WorkflowModel, data: Model, options) { // TODO: change to map filter format to calculation format // const calculation = toCalculation(condition); const { repository, model } = (this.constructor).database.getCollection(collection); + const { transaction } = options; const count = await repository.count({ filter: { $and: [ condition, { [model.primaryKeyAttribute]: data[model.primaryKeyAttribute] } ] - } + }, + transaction }); if (!count) {