( trx: DbTransaction, tableId: string, count: number, requestedPositions?: number[] )
| 123 | * original order; otherwise returns a contiguous append range. |
| 124 | */ |
| 125 | export async function reserveBatchPositions( |
| 126 | trx: DbTransaction, |
| 127 | tableId: string, |
| 128 | count: number, |
| 129 | requestedPositions?: number[] |
| 130 | ): Promise<number[]> { |
| 131 | await acquireRowOrderLock(trx, tableId) |
| 132 | if (requestedPositions && requestedPositions.length > 0) { |
| 133 | for (const pos of [...requestedPositions].sort((a, b) => a - b)) { |
| 134 | await shiftRowsUpFrom(trx, tableId, pos) |
| 135 | } |
| 136 | return requestedPositions |
| 137 | } |
| 138 | const start = await nextRowPosition(trx, tableId) |
| 139 | return Array.from({ length: count }, (_, i) => start + i) |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Recompacts row positions to be contiguous after a bulk delete. With |
no test coverage detected