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

Function batchInsertRows

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

Source from the content-addressed store, hash-verified

195 * @throws Error if validation fails or capacity exceeded
196 */
197export async function batchInsertRows(
198 data: BatchInsertData,
199 table: TableDefinition,
200 requestId: string
201): Promise<TableRow[]> {
202 // Best-effort capacity check against the workspace's current plan limit. Import
203 // paths call `batchInsertRowsWithTx` directly and gate capacity up front instead.
204 const rowLimit = await assertRowCapacity({
205 workspaceId: table.workspaceId,
206 currentRowCount: table.rowCount,
207 addedRows: data.rows.length,
208 })
209
210 const result = await db.transaction((trx) => batchInsertRowsWithTx(trx, data, table, requestId))
211 notifyTableRowUsage({
212 workspaceId: table.workspaceId,
213 currentRowCount: table.rowCount,
214 addedRows: result.length,
215 limit: rowLimit,
216 })
217 dispatchAfterBatchInsert(table, result, requestId, data.userId)
218 return result
219}
220
221/**
222 * Transaction-bound variant of `batchInsertRows`. Validates rows and unique

Callers 6

batchInsertAllFunction · 0.90
executeFunction · 0.90
update-row.test.tsFile · 0.90
handleBatchInsertFunction · 0.90
insertRowsFunction · 0.90
handleBatchInsertFunction · 0.90

Calls 4

assertRowCapacityFunction · 0.90
notifyTableRowUsageFunction · 0.90
batchInsertRowsWithTxFunction · 0.85
dispatchAfterBatchInsertFunction · 0.85

Tested by

no test coverage detected