Add table ID to row deletion requests that only contain string IDs
This commit is contained in:
parent
61bce0163c
commit
da122d2ac1
2 changed files with 13 additions and 1 deletions
|
@ -138,7 +138,7 @@ async function processDeleteRowsRequest(ctx: UserCtx<DeleteRowRequest>) {
|
||||||
const { tableId } = utils.getSourceId(ctx)
|
const { tableId } = utils.getSourceId(ctx)
|
||||||
|
|
||||||
const processedRows = request.rows.map(row => {
|
const processedRows = request.rows.map(row => {
|
||||||
let processedRow: Row = typeof row == "string" ? { _id: row } : row
|
let processedRow: Row = typeof row == "string" ? { _id: row, tableId } : row
|
||||||
return !processedRow._rev
|
return !processedRow._rev
|
||||||
? addRev(fixRow(processedRow, ctx.params), tableId)
|
? addRev(fixRow(processedRow, ctx.params), tableId)
|
||||||
: fixRow(processedRow, ctx.params)
|
: fixRow(processedRow, ctx.params)
|
||||||
|
|
|
@ -1138,6 +1138,18 @@ describe.each([
|
||||||
await assertRowUsage(isInternal ? rowUsage - 1 : rowUsage)
|
await assertRowUsage(isInternal ? rowUsage - 1 : rowUsage)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should be able to delete a row with ID only", async () => {
|
||||||
|
const createdRow = await config.api.row.save(table._id!, {})
|
||||||
|
const rowUsage = await getRowUsage()
|
||||||
|
|
||||||
|
const res = await config.api.row.bulkDelete(table._id!, {
|
||||||
|
rows: [createdRow._id!],
|
||||||
|
})
|
||||||
|
expect(res[0]._id).toEqual(createdRow._id)
|
||||||
|
expect(res[0].tableId).toEqual(table._id!)
|
||||||
|
await assertRowUsage(isInternal ? rowUsage - 1 : rowUsage)
|
||||||
|
})
|
||||||
|
|
||||||
it("should be able to bulk delete rows, including a row that doesn't exist", async () => {
|
it("should be able to bulk delete rows, including a row that doesn't exist", async () => {
|
||||||
const createdRow = await config.api.row.save(table._id!, {})
|
const createdRow = await config.api.row.save(table._id!, {})
|
||||||
const createdRow2 = await config.api.row.save(table._id!, {})
|
const createdRow2 = await config.api.row.save(table._id!, {})
|
||||||
|
|
Loading…
Reference in a new issue