MCPcopy Index your code
hub / github.com/Effect-TS/effect / run

Function run

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

Source from the content-addressed store, hash-verified

140 }
141
142 const run = (
143 sql: string,
144 params: ReadonlyArray<unknown> = [],
145 rowMode: "object" | "array" = "object"
146 ) =>
147 Effect.try({
148 try: () => {
149 const results: Array<any> = []
150 for (const stmt of sqlite3.statements(db, sql)) {
151 let columns: Array<string> | undefined
152 sqlite3.bind_collection(stmt, params as any)
153 while (sqlite3.step(stmt) === WaSqlite.SQLITE_ROW) {
154 columns = columns ?? sqlite3.column_names(stmt)
155 const row = sqlite3.row(stmt)
156 if (rowMode === "object") {
157 const obj: Record<string, any> = {}
158 for (let i = 0; i < columns.length; i++) {
159 obj[columns[i]] = row[i]
160 }
161 results.push(obj)
162 } else {
163 results.push(row)
164 }
165 }
166 }
167 return results
168 },
169 catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" })
170 })
171
172 return identity<SqliteConnection>({
173 execute(sql, params, transformRows) {

Callers 3

executeFunction · 0.70
executeRawFunction · 0.70
executeValuesFunction · 0.70

Calls 4

sendFunction · 0.70
stepMethod · 0.65
getFiberRefMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected