(params: {
tableId: string
rowId: string
workspaceId: string
})
| 420 | * gap. Returns `false` when no row matched. |
| 421 | */ |
| 422 | export async function deleteOrderedRow(params: { |
| 423 | tableId: string |
| 424 | rowId: string |
| 425 | workspaceId: string |
| 426 | }): Promise<boolean> { |
| 427 | const { tableId, rowId, workspaceId } = params |
| 428 | return db.transaction(async (trx) => { |
| 429 | await setTableTxTimeouts(trx) |
| 430 | const [deleted] = await trx |
| 431 | .delete(userTableRows) |
| 432 | .where( |
| 433 | and( |
| 434 | eq(userTableRows.id, rowId), |
| 435 | eq(userTableRows.tableId, tableId), |
| 436 | eq(userTableRows.workspaceId, workspaceId) |
| 437 | ) |
| 438 | ) |
| 439 | .returning({ position: userTableRows.position }) |
| 440 | if (!deleted) return false |
| 441 | // Fractional ordering: deleting a row never changes another row's order_key, |
| 442 | // so the O(N) position reshift is skipped entirely. |
| 443 | if (!(await isFeatureEnabled('tables-fractional-ordering'))) { |
| 444 | await shiftRowsDownAfter(trx, tableId, deleted.position) |
| 445 | } |
| 446 | return true |
| 447 | }) |
| 448 | } |
| 449 | |
| 450 | /** |
| 451 | * Deletes the given row ids in batches within one transaction, then recompacts |
no test coverage detected