Get latest RevId if not provided
This commit is contained in:
parent
8858a416ef
commit
d85e022182
|
@ -81,7 +81,7 @@ const duplicateRowHandler = async (action, context) => {
|
||||||
|
|
||||||
const deleteRowHandler = async action => {
|
const deleteRowHandler = async action => {
|
||||||
const { tableId, revId, rowId } = action.parameters
|
const { tableId, revId, rowId } = action.parameters
|
||||||
if (tableId && revId && rowId) {
|
if (tableId && rowId) {
|
||||||
try {
|
try {
|
||||||
await API.deleteRow({ tableId, rowId, revId })
|
await API.deleteRow({ tableId, rowId, revId })
|
||||||
notificationStore.actions.success("Row deleted")
|
notificationStore.actions.success("Row deleted")
|
||||||
|
|
|
@ -35,7 +35,7 @@ export const buildRowEndpoints = API => ({
|
||||||
* @param revId the rev of the row to delete
|
* @param revId the rev of the row to delete
|
||||||
*/
|
*/
|
||||||
deleteRow: async ({ tableId, rowId, revId }) => {
|
deleteRow: async ({ tableId, rowId, revId }) => {
|
||||||
if (!tableId || !rowId || !revId) {
|
if (!tableId || !rowId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return await API.delete({
|
return await API.delete({
|
||||||
|
|
|
@ -259,8 +259,9 @@ exports.find = async ctx => {
|
||||||
|
|
||||||
exports.destroy = async function (ctx) {
|
exports.destroy = async function (ctx) {
|
||||||
const db = getAppDB()
|
const db = getAppDB()
|
||||||
const { _id, _rev } = ctx.request.body
|
const { _id } = ctx.request.body
|
||||||
let row = await db.get(_id)
|
let row = await db.get(_id)
|
||||||
|
let _rev = ctx.request.body._rev || row._rev
|
||||||
|
|
||||||
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"
|
||||||
|
|
Loading…
Reference in New Issue