(executor: DbOrTx, tableId: string)
| 68 | |
| 69 | /** Largest `order_key` for a table, or `null` when empty — the append anchor for new keys. */ |
| 70 | export async function maxOrderKey(executor: DbOrTx, tableId: string): Promise<string | null> { |
| 71 | const [{ maxKey }] = await executor |
| 72 | .select({ maxKey: sql<string | null>`max(${userTableRows.orderKey})` }) |
| 73 | .from(userTableRows) |
| 74 | .where(eq(userTableRows.tableId, tableId)) |
| 75 | return maxKey ?? null |
| 76 | } |
| 77 | |
| 78 | /** Shifts every row at or after `position` up by one (`position + 1`). */ |
| 79 | export async function shiftRowsUpFrom(trx: DbTransaction, tableId: string, position: number) { |
no test coverage detected