1
0
Fork 0
mirror of synced 2024-07-15 03:05:57 +12:00

Fix for attachment cleanup on internal row delete.

This commit is contained in:
Dean 2022-11-13 18:08:48 +00:00
parent 0cf55b933e
commit 8f058e222b

View file

@ -142,15 +142,15 @@ export async function destroy(ctx: any) {
const tableToDelete = await db.get(ctx.params.tableId)
// Delete all rows for that table
const rows = await db.allDocs(
const rowsData = await db.allDocs(
getRowParams(ctx.params.tableId, null, {
include_docs: true,
})
)
await db.bulkDocs(
rows.rows.map((row: any) => ({ ...row.doc, _deleted: true }))
rowsData.rows.map((row: any) => ({ ...row.doc, _deleted: true }))
)
await quotas.removeRows(rows.rows.length, {
await quotas.removeRows(rowsData.rows.length, {
tableId: ctx.params.tableId,
})
@ -179,7 +179,9 @@ export async function destroy(ctx: any) {
oldTable: null,
deletion: true,
})
await cleanupAttachments(tableToDelete, { rows })
await cleanupAttachments(tableToDelete, {
rows: rowsData.rows.map((row: any) => row.doc),
})
return tableToDelete
}