( tableId: string, workspaceId: string, rowIds: string[] )
| 584 | * position. Returns the count deleted. |
| 585 | */ |
| 586 | export async function deletePageByIds( |
| 587 | tableId: string, |
| 588 | workspaceId: string, |
| 589 | rowIds: string[] |
| 590 | ): Promise<number> { |
| 591 | let deleted = 0 |
| 592 | for (let i = 0; i < rowIds.length; i += TABLE_LIMITS.DELETE_BATCH_SIZE) { |
| 593 | const batch = rowIds.slice(i, i + TABLE_LIMITS.DELETE_BATCH_SIZE) |
| 594 | const rows = await db.transaction(async (trx) => { |
| 595 | await setTableTxTimeouts(trx, { statementMs: 60_000 }) |
| 596 | return trx |
| 597 | .delete(userTableRows) |
| 598 | .where( |
| 599 | and( |
| 600 | eq(userTableRows.tableId, tableId), |
| 601 | eq(userTableRows.workspaceId, workspaceId), |
| 602 | inArray(userTableRows.id, batch) |
| 603 | ) |
| 604 | ) |
| 605 | .returning({ id: userTableRows.id }) |
| 606 | }) |
| 607 | deleted += rows.length |
| 608 | } |
| 609 | return deleted |
| 610 | } |
| 611 | |
| 612 | /** |
| 613 | * Applies a JSONB-merge patch (`data || patchJson`) to a page of row ids, committed in |
no test coverage detected