2022-02-20 21:23:39 +08:00
|
|
|
import { JOB_STATUS } from "../constants";
|
|
|
|
import FlowNodeModel from "../models/FlowNode";
|
|
|
|
|
|
|
|
export default {
|
2022-06-24 23:28:49 +08:00
|
|
|
async run(node: FlowNodeModel, input, processor) {
|
2022-02-20 21:23:39 +08:00
|
|
|
const {
|
|
|
|
collection,
|
|
|
|
params = {}
|
2022-06-24 23:28:49 +08:00
|
|
|
} = node.config;
|
2022-02-20 21:23:39 +08:00
|
|
|
|
2022-06-24 23:28:49 +08:00
|
|
|
const repo = (<typeof FlowNodeModel>node.constructor).database.getRepository(collection);
|
2022-06-20 23:29:21 +08:00
|
|
|
const options = processor.getParsedValue(params);
|
2022-02-20 21:23:39 +08:00
|
|
|
const result = await repo.create({
|
2022-04-14 00:05:13 +08:00
|
|
|
...options,
|
2022-10-19 19:01:33 +08:00
|
|
|
context: processor.options._context,
|
2022-06-20 23:29:21 +08:00
|
|
|
transaction: processor.transaction
|
2022-02-20 21:23:39 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
2022-05-13 13:26:49 +08:00
|
|
|
// NOTE: get() for non-proxied instance (#380)
|
|
|
|
result: result.get(),
|
2022-02-20 21:23:39 +08:00
|
|
|
status: JOB_STATUS.RESOLVED
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|