tachybase_todo/packages/plugins/workflow/src/server/instructions/update.ts
Junyi 4a3cb6e65f
Refactor(plugin workflow): move client files into plugin (#556)
* refactor(plugin-workflow): move client files into plugin

* fix(client): fix package path block build

* test(plugin-workflow): trigger ci
2022-06-29 23:42:03 +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(node: FlowNodeModel, input, processor: Processor) {
const {
collection,
multiple = false,
params = {}
} = node.config;
const repo = (<typeof FlowNodeModel>node.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
};
}
}