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

Function insertRows

apps/sim/app/api/table/import-csv/route.ts:109–124  ·  view source on GitHub ↗
(
      rows: Record<string, unknown>[],
      state: ImportState,
      currentRowCount: number
    )

Source from the content-addressed store, hash-verified

107 }
108
109 const insertRows = async (
110 rows: Record<string, unknown>[],
111 state: ImportState,
112 currentRowCount: number
113 ) => {
114 if (rows.length === 0) return 0
115 const coerced = coerceRowsForTable(rows, state.schema, state.headerToColumn)
116 const result = await batchInsertRows(
117 { tableId: state.table.id, rows: coerced, workspaceId, userId },
118 // The created table's rowCount is frozen at 0; pass the running total so the
119 // per-batch capacity check sees cumulative rows, not an always-empty table.
120 { ...state.table, rowCount: currentRowCount },
121 generateId().slice(0, 8)
122 )
123 return result.length
124 }
125
126 /** Infer the schema from the buffered sample and create the (empty) table. */
127 const buildTable = async (sampleRows: Record<string, unknown>[]): Promise<ImportState> => {

Callers 1

route.tsFile · 0.85

Calls 3

coerceRowsForTableFunction · 0.90
batchInsertRowsFunction · 0.90
generateIdFunction · 0.90

Tested by

no test coverage detected