Fixing an issue with deletion action.

This commit is contained in:
mike12345567 2020-09-17 16:28:48 +01:00
parent 22ef6eb4d3
commit 53bbcd9928
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 db = new CouchDB(ctx.user.instanceId)
const record = await db.get(ctx.params.recordId) const record = await db.get(ctx.params.recordId)
if (record.modelId !== ctx.params.modelId) { 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 return
} }
ctx.body = await db.remove(ctx.params.recordId, ctx.params.revId) ctx.body = await db.remove(ctx.params.recordId, ctx.params.revId)
ctx.status = 200 ctx.status = 200
// for workflows
ctx.record = record
emitEvent(`record:delete`, ctx, record) emitEvent(`record:delete`, ctx, record)
} }

View File

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