From 5c94210d72d6652a207c407d34c0ffb92ad58663 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 14 Sep 2020 11:47:52 +0100 Subject: [PATCH] Adding delete record for when we build in contextual awareness. --- packages/server/src/workflows/actions.js | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/server/src/workflows/actions.js b/packages/server/src/workflows/actions.js index 27448700f3..1dd3aa694d 100644 --- a/packages/server/src/workflows/actions.js +++ b/packages/server/src/workflows/actions.js @@ -77,6 +77,31 @@ let BUILTIN_ACTIONS = { } } }, + DELETE_RECORD: async function({ args, context }) { + const { model, ...record } = args.record + // TODO: better logging of when actions are missed due to missing parameters + if (record.recordId == null || record.revId == null) { + return + } + let ctx = { + params: { + modelId: model._id, + recordId: record.recordId, + revId: record.revId, + }, + user: { instanceId: context.instanceId }, + } + + try { + await recordController.destroy(ctx) + } catch (err) { + console.error(err) + return { + record: null, + error: err.message, + } + } + }, } module.exports.getAction = async function(actionName) {