1
0
Fork 0
mirror of synced 2024-07-05 06:20:55 +12:00

Fixing an issue with deletion action.

This commit is contained in:
mike12345567 2020-09-17 16:28:48 +01:00
parent cc5994539d
commit 05f3666257
2 changed files with 4 additions and 1 deletions

View file

@ -183,11 +183,13 @@ exports.destroy = async function(ctx) {
const db = new CouchDB(ctx.user.instanceId)
const record = await db.get(ctx.params.recordId)
if (record.modelId !== ctx.params.modelId) {
ctx.throw(400, "Supplied modelId doe not match the record's modelId")
ctx.throw(400, "Supplied modelId doesn't match the record's modelId")
return
}
ctx.body = await db.remove(ctx.params.recordId, ctx.params.revId)
ctx.status = 200
// for workflows
ctx.record = record
emitEvent(`record:delete`, ctx, record)
}

View file

@ -66,6 +66,7 @@ module.exports.run = async function({ inputs, instanceId }) {
await recordController.destroy(ctx)
return {
response: ctx.body,
record: ctx.record,
success: ctx.status === 200,
}
} catch (err) {