From 432d876dff7a38674ab91e764c0bc3fdf910391b Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 14 Sep 2021 17:49:01 +0100 Subject: [PATCH] Backbone of query definition. --- .../server/src/automations/steps/queryRows.js | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 packages/server/src/automations/steps/queryRows.js diff --git a/packages/server/src/automations/steps/queryRows.js b/packages/server/src/automations/steps/queryRows.js new file mode 100644 index 0000000000..8b01bd9755 --- /dev/null +++ b/packages/server/src/automations/steps/queryRows.js @@ -0,0 +1,74 @@ +//const rowController = require("../../api/controllers/row") + +const SortOrders = { + ASCENDING: "ascending", + DESCENDING: "descending", +} + +const SortOrdersPretty = { + [SortOrders.ASCENDING]: "Ascending", + [SortOrders.DESCENDING]: "Descending", +} + +exports.definition = { + description: "Query rows from the database", + icon: "ri-search-line", + name: "Query rows", + tagline: "Query rows from {{inputs.enriched.table.name}} table", + type: "ACTION", + stepId: "QUERY_ROWS", + internal: true, + inputs: {}, + schema: { + inputs: { + properties: { + tableId: { + type: "string", + customType: "table", + title: "Table", + }, + filters: { + type: "object", + customType: "filters", + title: "Filtering", + }, + sortColumn: { + type: "string", + title: "Sort Column", + customType: "column", + }, + sortOrder: { + type: "string", + title: "Sort Order", + enum: Object.values(SortOrders), + pretty: Object.values(SortOrdersPretty), + }, + limit: { + type: "number", + title: "Limit", + }, + }, + required: ["tableId", "filters"], + }, + outputs: { + properties: { + row: { + type: "array", + customType: "rows", + description: "The rows that were found", + }, + success: { + type: "boolean", + description: "Whether the deletion was successful", + }, + }, + required: ["rows", "success"], + }, + }, +} + +exports.run = async function ({ inputs, appId }) { + console.log(inputs) + console.log(appId) + // TODO: use the search controller +}