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

Function updatePageByIds

apps/sim/lib/table/rows/ordering.ts:617–644  ·  view source on GitHub ↗
(
  tableId: string,
  workspaceId: string,
  rowIds: string[],
  patchJson: string
)

Source from the content-addressed store, hash-verified

615 * makes incremental, resumable progress. Returns the number of rows updated.
616 */
617export async function updatePageByIds(
618 tableId: string,
619 workspaceId: string,
620 rowIds: string[],
621 patchJson: string
622): Promise<number> {
623 const now = new Date()
624 let updated = 0
625 for (let i = 0; i < rowIds.length; i += TABLE_LIMITS.UPDATE_BATCH_SIZE) {
626 const batch = rowIds.slice(i, i + TABLE_LIMITS.UPDATE_BATCH_SIZE)
627 const rows = await db.transaction(async (trx) => {
628 await setTableTxTimeouts(trx, { statementMs: 60_000 })
629 return trx
630 .update(userTableRows)
631 .set({ data: sql`${userTableRows.data} || ${patchJson}::jsonb`, updatedAt: now })
632 .where(
633 and(
634 eq(userTableRows.tableId, tableId),
635 eq(userTableRows.workspaceId, workspaceId),
636 inArray(userTableRows.id, batch)
637 )
638 )
639 .returning({ id: userTableRows.id })
640 })
641 updated += rows.length
642 }
643 return updated
644}

Callers 1

runTableUpdateFunction · 0.90

Calls 3

setTableTxTimeoutsFunction · 0.90
setMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected