MCPcopy
hub / github.com/simstudioai/sim / nextImportStartPosition

Function nextImportStartPosition

apps/sim/lib/table/rows/ordering.ts:25–33  ·  view source on GitHub ↗
(tableId: string)

Source from the content-addressed store, hash-verified

23 * contiguous positions from this offset without per-batch position scans.
24 */
25export async function nextImportStartPosition(tableId: string): Promise<number> {
26 const [{ maxPos }] = await db
27 .select({
28 maxPos: sql<number>`coalesce(max(${userTableRows.position}), -1)`.mapWith(Number),
29 })
30 .from(userTableRows)
31 .where(eq(userTableRows.tableId, tableId))
32 return maxPos + 1
33}
34
35/**
36 * Append anchor `order_key` for an import — `max(order_key)`, or null when empty. Read once,

Callers 1

runTableImportFunction · 0.90

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected