UNPKG

@tachybase/module-workflow

Version:

A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.

49 lines (48 loc) 1.77 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var SQLInstruction_exports = {}; __export(SQLInstruction_exports, { default: () => SQLInstruction_default }); module.exports = __toCommonJS(SQLInstruction_exports); var import__ = require("../.."); class SQLInstruction_default extends import__.Instruction { async run(node, input, processor) { const { db } = this.workflow.app.dataSourceManager.dataSources.get( node.config.dataSource || "main" ).collectionManager; if (!db) { throw new Error(`type of data source "${node.config.dataSource}" is not database`); } const sql = processor.getParsedValue(node.config.sql || "", node.id).trim(); if (!sql) { return { status: import__.JOB_STATUS.RESOLVED }; } const result = await db.sequelize.query(sql, { transaction: processor.transaction // plain: true, // model: db.getCollection(node.config.collection).model }); return { result, status: import__.JOB_STATUS.RESOLVED }; } }