Fixing internal delete.
This commit is contained in:
parent
9719e26de2
commit
bf47a66442
|
@ -14,8 +14,11 @@ export async function saveRow(row, tableId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteRow(row) {
|
export async function deleteRow(row) {
|
||||||
const DELETE_ROWS_URL = `/api/${row.tableId}/rows/${row._id}/${row._rev}`
|
const DELETE_ROWS_URL = `/api/${row.tableId}/rows`
|
||||||
return api.delete(DELETE_ROWS_URL)
|
return api.delete(DELETE_ROWS_URL, {
|
||||||
|
_id: row._id,
|
||||||
|
_rev: row._rev,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchDataForView(view) {
|
export async function fetchDataForView(view) {
|
||||||
|
|
|
@ -65,7 +65,11 @@ export const deleteRow = async ({ tableId, rowId, revId }) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const res = await API.del({
|
const res = await API.del({
|
||||||
url: `/api/${tableId}/rows/${rowId}/${revId}`,
|
url: `/api/${tableId}/rows`,
|
||||||
|
body: {
|
||||||
|
_id: rowId,
|
||||||
|
_rev: revId,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
res.error
|
res.error
|
||||||
? notificationStore.danger("An error has occurred")
|
? notificationStore.danger("An error has occurred")
|
||||||
|
@ -84,11 +88,10 @@ export const deleteRows = async ({ tableId, rows }) => {
|
||||||
if (!tableId || !rows) {
|
if (!tableId || !rows) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const res = await API.post({
|
const res = await API.del({
|
||||||
url: `/api/${tableId}/rows`,
|
url: `/api/${tableId}/rows`,
|
||||||
body: {
|
body: {
|
||||||
rows,
|
rows,
|
||||||
type: "delete",
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
res.error
|
res.error
|
||||||
|
|
|
@ -227,8 +227,8 @@ exports.find = async (ctx) => {
|
||||||
exports.destroy = async function (ctx) {
|
exports.destroy = async function (ctx) {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
const { rowId, revId } = ctx.request.body
|
const { _id, _rev } = ctx.request.body
|
||||||
const row = await db.get(rowId)
|
const row = await db.get(_id)
|
||||||
|
|
||||||
if (row.tableId !== ctx.params.tableId) {
|
if (row.tableId !== ctx.params.tableId) {
|
||||||
throw "Supplied tableId doesn't match the row's 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) {
|
if (ctx.params.tableId === InternalTables.USER_METADATA) {
|
||||||
ctx.params = {
|
ctx.params = {
|
||||||
id: rowId,
|
id: _id,
|
||||||
}
|
}
|
||||||
await userController.destroyMetadata(ctx)
|
await userController.destroyMetadata(ctx)
|
||||||
return { response: ctx.body, row }
|
return { response: ctx.body, row }
|
||||||
} else {
|
} else {
|
||||||
const response = await db.remove(rowId, revId)
|
const response = await db.remove(_id, _rev)
|
||||||
return { response, row }
|
return { response, row }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue