nocobase/packages/plugins/@nocobase/plugin-workflow-sql/src/server/SQLInstruction.ts
Junyi f7b62ed42b
fix(plugin-workflow): fix sql transaction and locale (#3444)
* fix(plugin-workflow): fix sql transaction and locale

* fix(plugin-workflow): fix locale
2024-01-27 09:37:40 +08:00

25 lines
704 B
TypeScript

import { Processor, Instruction, JOB_STATUS, FlowNodeModel } from '@nocobase/plugin-workflow';
export default class extends Instruction {
async run(node: FlowNodeModel, input, processor: Processor) {
const { sequelize } = (<typeof FlowNodeModel>node.constructor).database;
const sql = processor.getParsedValue(node.config.sql ?? '', node.id).trim();
if (!sql) {
return {
status: JOB_STATUS.RESOLVED,
};
}
const result = await sequelize.query(sql, {
transaction: processor.transaction,
// plain: true,
// model: db.getCollection(node.config.collection).model
});
return {
result,
status: JOB_STATUS.RESOLVED,
};
}
}