tachybase_todo/packages/plugins/workflow/src/instructions/update.ts
Junyi ecf82208eb
refactor(plugin-workflow): abstract to classes (#515)
* refactor(plugin-workflow): abstract to classes

* fix(plugin-workflow): add indexes and fix cases

* test(plugin-workflow): skip schedule cases
2022-06-20 23:29:21 +08:00

26 lines
675 B
TypeScript

import FlowNodeModel from "../models/FlowNode";
import Processor from "../Processor";
import { JOB_STATUS } from "../constants";
export default {
async run(this: FlowNodeModel, input, processor: Processor) {
const {
collection,
multiple = false,
params = {}
} = this.config;
const repo = (<typeof FlowNodeModel>this.constructor).database.getRepository(collection);
const options = processor.getParsedValue(params);
const result = await repo.update({
...options,
transaction: processor.transaction
});
return {
result: multiple ? result : (result[0] || null),
status: JOB_STATUS.RESOLVED
};
}
}