Fixing internal delete.

This commit is contained in:
mike12345567 2021-06-14 13:52:06 +01:00
parent 6685ebaa7b
commit 146a72f61d
3 changed files with 15 additions and 9 deletions

View File

@ -14,8 +14,11 @@ export async function saveRow(row, tableId) {
}
export async function deleteRow(row) {
const DELETE_ROWS_URL = `/api/${row.tableId}/rows/${row._id}/${row._rev}`
return api.delete(DELETE_ROWS_URL)
const DELETE_ROWS_URL = `/api/${row.tableId}/rows`
return api.delete(DELETE_ROWS_URL, {
_id: row._id,
_rev: row._rev,
})
}
export async function fetchDataForView(view) {

View File

@ -65,7 +65,11 @@ export const deleteRow = async ({ tableId, rowId, revId }) => {
return
}
const res = await API.del({
url: `/api/${tableId}/rows/${rowId}/${revId}`,
url: `/api/${tableId}/rows`,
body: {
_id: rowId,
_rev: revId,
}
})
res.error
? notificationStore.danger("An error has occurred")
@ -84,11 +88,10 @@ export const deleteRows = async ({ tableId, rows }) => {
if (!tableId || !rows) {
return
}
const res = await API.post({
const res = await API.del({
url: `/api/${tableId}/rows`,
body: {
rows,
type: "delete",
},
})
res.error

View File

@ -227,8 +227,8 @@ exports.find = async (ctx) => {
exports.destroy = async function (ctx) {
const appId = ctx.appId
const db = new CouchDB(appId)
const { rowId, revId } = ctx.request.body
const row = await db.get(rowId)
const { _id, _rev } = ctx.request.body
const row = await db.get(_id)
if (row.tableId !== ctx.params.tableId) {
throw "Supplied tableId doesn't match the row's tableId"
@ -241,12 +241,12 @@ exports.destroy = async function (ctx) {
})
if (ctx.params.tableId === InternalTables.USER_METADATA) {
ctx.params = {
id: rowId,
id: _id,
}
await userController.destroyMetadata(ctx)
return { response: ctx.body, row }
} else {
const response = await db.remove(rowId, revId)
const response = await db.remove(_id, _rev)
return { response, row }
}
}