(
table: TableDefinition,
after: { orderKey: string; id: string } | null,
limit: number
)
| 215 | * applies, like every user-facing read. |
| 216 | */ |
| 217 | export async function selectExportRowPage( |
| 218 | table: TableDefinition, |
| 219 | after: { orderKey: string; id: string } | null, |
| 220 | limit: number |
| 221 | ): Promise<Array<{ id: string; data: RowData; orderKey: string }>> { |
| 222 | const deleteMask = await pendingDeleteMask(table) |
| 223 | const rows = await db |
| 224 | .select({ id: userTableRows.id, data: userTableRows.data, orderKey: userTableRows.orderKey }) |
| 225 | .from(userTableRows) |
| 226 | .where( |
| 227 | and( |
| 228 | eq(userTableRows.tableId, table.id), |
| 229 | eq(userTableRows.workspaceId, table.workspaceId), |
| 230 | deleteMask, |
| 231 | after |
| 232 | ? sql`(${userTableRows.orderKey}, ${userTableRows.id}) > (${after.orderKey}, ${after.id})` |
| 233 | : undefined |
| 234 | ) |
| 235 | ) |
| 236 | .orderBy(asc(userTableRows.orderKey), asc(userTableRows.id)) |
| 237 | .limit(limit) |
| 238 | return rows as Array<{ id: string; data: RowData; orderKey: string }> |
| 239 | } |
| 240 | |
| 241 | /** How long a terminal export stays listable (and re-downloadable from the tray). */ |
| 242 | const EXPORT_JOB_VISIBILITY_MS = 10 * 60 * 1000 |
no test coverage detected