Test deleting multiple rows
This commit is contained in:
parent
3335c86a84
commit
76e836ca55
|
@ -146,7 +146,7 @@ async function deleteRows(ctx: UserCtx<DeleteRowRequest>) {
|
|||
const rowDeletes: Row[] = await processDeleteRowsRequest(ctx)
|
||||
deleteRequest.rows = rowDeletes
|
||||
|
||||
let { rows } = await quotas.addQuery<any>(
|
||||
const { rows } = await quotas.addQuery(
|
||||
() => pickApi(tableId).bulkDestroy(ctx),
|
||||
{
|
||||
datasourceId: tableId,
|
||||
|
|
|
@ -350,7 +350,7 @@ router
|
|||
ctx.params.tableId = utils.extractViewInfoFromID(
|
||||
ctx.params.viewId
|
||||
).tableId
|
||||
next()
|
||||
return next()
|
||||
},
|
||||
rowController.destroy
|
||||
)
|
||||
|
|
|
@ -1225,6 +1225,41 @@ describe("/rows", () => {
|
|||
expectStatus: 404,
|
||||
})
|
||||
})
|
||||
|
||||
it("should be able to delete multiple rows", async () => {
|
||||
const table = await config.createTable(userTable())
|
||||
const tableId = table._id!
|
||||
const view = await config.api.viewV2.create({
|
||||
tableId,
|
||||
columns: {
|
||||
name: { visible: true },
|
||||
address: { visible: true },
|
||||
},
|
||||
})
|
||||
|
||||
const rows = [
|
||||
await config.createRow(),
|
||||
await config.createRow(),
|
||||
await config.createRow(),
|
||||
]
|
||||
const rowUsage = await getRowUsage()
|
||||
const queryUsage = await getQueryUsage()
|
||||
|
||||
await config.api.viewV2.row.delete(view.id, {
|
||||
rows: [rows[0], rows[2]],
|
||||
})
|
||||
|
||||
await assertRowUsage(rowUsage - 2)
|
||||
await assertQueryUsage(queryUsage + 1)
|
||||
|
||||
await config.api.row.get(tableId, rows[0]._id!, {
|
||||
expectStatus: 404,
|
||||
})
|
||||
await config.api.row.get(tableId, rows[2]._id!, {
|
||||
expectStatus: 404,
|
||||
})
|
||||
await config.api.row.get(tableId, rows[1]._id!, { expectStatus: 200 })
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue