fix(plugin-workflow): fix collection trigger transaction (#474)

This commit is contained in:
Junyi 2022-06-05 21:58:06 +08:00 committed by GitHub
parent c129abfeb6
commit 4e19571c08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 } = (<typeof WorkflowModel>this.constructor).database.getCollection(collection);
const { transaction } = options;
const count = await repository.count({
filter: {
$and: [
condition,
{ [model.primaryKeyAttribute]: data[model.primaryKeyAttribute] }
]
}
},
transaction
});
if (!count) {