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

Function replaceTableRows

apps/sim/lib/table/rows/service.ts:358–378  ·  view source on GitHub ↗
(
  data: ReplaceRowsData,
  table: TableDefinition,
  requestId: string
)

Source from the content-addressed store, hash-verified

356 * @throws Error if validation fails or capacity exceeded
357 */
358export async function replaceTableRows(
359 data: ReplaceRowsData,
360 table: TableDefinition,
361 requestId: string
362): Promise<ReplaceRowsResult> {
363 // All existing rows are deleted, so the footprint is just the new set. Checked
364 // before the tx opens — never inside it (the plan lookup is a separate pool read).
365 const rowLimit = await assertRowCapacity({
366 workspaceId: table.workspaceId,
367 currentRowCount: 0,
368 addedRows: data.rows.length,
369 })
370 const result = await db.transaction((trx) => replaceTableRowsWithTx(trx, data, table, requestId))
371 notifyTableRowUsage({
372 workspaceId: table.workspaceId,
373 currentRowCount: 0,
374 addedRows: result.insertedCount,
375 limit: rowLimit,
376 })
377 return result
378}
379
380/**
381 * Transaction-bound variant of `replaceTableRows`. Caller opens the transaction.

Callers 3

executeFunction · 0.90
replaceTableRowsFromWireFunction · 0.90
update-row.test.tsFile · 0.90

Calls 3

assertRowCapacityFunction · 0.90
notifyTableRowUsageFunction · 0.90
replaceTableRowsWithTxFunction · 0.85

Tested by

no test coverage detected