From 9b5ad2dacc93001f36764eae598cdc21b5a9c022 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Wed, 20 Apr 2022 11:51:01 +0100 Subject: [PATCH] Get latest RevId if not provided --- packages/client/src/utils/buttonActions.js | 2 +- packages/frontend-core/src/api/rows.js | 2 +- packages/server/src/api/controllers/row/internal.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index f851a623c0..4e35cb2e54 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -81,7 +81,7 @@ const duplicateRowHandler = async (action, context) => { const deleteRowHandler = async action => { const { tableId, revId, rowId } = action.parameters - if (tableId && revId && rowId) { + if (tableId && rowId) { try { await API.deleteRow({ tableId, rowId, revId }) notificationStore.actions.success("Row deleted") diff --git a/packages/frontend-core/src/api/rows.js b/packages/frontend-core/src/api/rows.js index 6a0d278cf7..9f980678c5 100644 --- a/packages/frontend-core/src/api/rows.js +++ b/packages/frontend-core/src/api/rows.js @@ -35,7 +35,7 @@ export const buildRowEndpoints = API => ({ * @param revId the rev of the row to delete */ deleteRow: async ({ tableId, rowId, revId }) => { - if (!tableId || !rowId || !revId) { + if (!tableId || !rowId) { return } return await API.delete({ diff --git a/packages/server/src/api/controllers/row/internal.js b/packages/server/src/api/controllers/row/internal.js index 68ff4ca88d..d8e18df43b 100644 --- a/packages/server/src/api/controllers/row/internal.js +++ b/packages/server/src/api/controllers/row/internal.js @@ -259,8 +259,9 @@ exports.find = async ctx => { exports.destroy = async function (ctx) { const db = getAppDB() - const { _id, _rev } = ctx.request.body + const { _id } = ctx.request.body let row = await db.get(_id) + let _rev = ctx.request.body._rev || row._rev if (row.tableId !== ctx.params.tableId) { throw "Supplied tableId doesn't match the row's tableId"