MCPcopy Create free account
hub / github.com/effect-app/libs / run

Function run

repos/effect/packages/sql/sqlite-wasm/src/SqliteClient.ts:169–197  ·  view source on GitHub ↗
(
        sql: string,
        params: ReadonlyArray<unknown> = [],
        rowMode: "object" | "array" = "object"
      )

Source from the content-addressed store, hash-verified

167 })
168 }
169
170 const run = (
171 sql: string,
172 params: ReadonlyArray<unknown> = [],
173 rowMode: "object" | "array" = "object"
174 ) =>
175 Effect.try({
176 try: () => {
177 const results: Array<any> = []
178 for (const stmt of sqlite3.statements(db, sql)) {
179 let columns: Array<string> | undefined
180 sqlite3.bind_collection(stmt, params as any)
181 while (sqlite3.step(stmt) === WaSqlite.SQLITE_ROW) {
182 columns = columns ?? sqlite3.column_names(stmt)
183 const row = sqlite3.row(stmt)
184 if (rowMode === "object") {
185 const obj: Record<string, any> = {}
186 for (let i = 0; i < columns.length; i++) {
187 Rec.assignProperty(obj, columns[i], row[i])
188 }
189 results.push(obj)
190 } else {
191 results.push(row)
192 }
193 }
194 }
195 return results
196 },
197 catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
198 })
199
200 return identity<SqliteConnection>({

Callers 4

executeFunction · 0.70
executeRawFunction · 0.70
executeValuesFunction · 0.70
executeValuesUnpreparedFunction · 0.70

Calls 5

pushMethod · 0.80
getRefMethod · 0.80
classifyErrorFunction · 0.70
sendFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected