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

Function executeStream

repos/effect/packages/sql/sqlite-wasm/src/SqliteClient.ts:217–241  ·  view source on GitHub ↗
(sql, params, transformRows)

Source from the content-addressed store, hash-verified

215 executeUnprepared(sql, params, transformRows) {
216 return this.execute(sql, params, transformRows)
217 },
218 executeStream(sql, params, transformRows) {
219 function* stream() {
220 for (const stmt of sqlite3.statements(db, sql)) {
221 let columns: Array<string> | undefined
222 sqlite3.bind_collection(stmt, params as any)
223 while (sqlite3.step(stmt) === WaSqlite.SQLITE_ROW) {
224 columns = columns ?? sqlite3.column_names(stmt)
225 const row = sqlite3.row(stmt)
226 const obj: Record<string, any> = {}
227 for (let i = 0; i < columns.length; i++) {
228 Rec.assignProperty(obj, columns[i], row[i])
229 }
230 yield obj
231 }
232 }
233 }
234 return Stream.suspend(() => Stream.fromIteratorSucceed(stream()[Symbol.iterator]())).pipe(
235 transformRows
236 ? Stream.mapArray((chunk) => transformRows(chunk) as any)
237 : identity,
238 Stream.mapError((cause) =>
239 new SqlError({ reason: classifyError(cause, "Failed to execute statement", "stream") })
240 )
241 )
242 },
243 export: Effect.try({
244 try: () => sqlite3.serialize(db, "main"),

Callers

nothing calls this directly

Calls 3

streamFunction · 0.70
classifyErrorFunction · 0.70
pipeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…