MCPcopy Index your code
hub / github.com/simstudioai/sim / maxOrderKey

Function maxOrderKey

apps/sim/lib/table/rows/ordering.ts:70–76  ·  view source on GitHub ↗
(executor: DbOrTx, tableId: string)

Source from the content-addressed store, hash-verified

68
69/** Largest `order_key` for a table, or `null` when empty — the append anchor for new keys. */
70export 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`). */
79export async function shiftRowsUpFrom(trx: DbTransaction, tableId: string, position: number) {

Callers 3

nextImportStartOrderKeyFunction · 0.85
resolveInsertOrderKeyFunction · 0.85

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected