1
0
Fork 0
mirror of synced 2024-10-01 01:28:51 +13:00

Adding delete record for when we build in contextual awareness.

This commit is contained in:
mike12345567 2020-09-14 11:47:52 +01:00
parent 535c4ca5aa
commit 5c94210d72

View file

@ -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) {