MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeSqlCommit

Function makeSqlCommit

packages/sql-kysely/src/internal/patch.ts:72–90  ·  view source on GitHub ↗
(client: Client.SqlClient)

Source from the content-addressed store, hash-verified

70
71/** @internal */
72const makeSqlCommit = (client: Client.SqlClient) => {
73 return function(this: Compilable, plugins: ReadonlyArray<KyselyPlugin>) {
74 const { parameters, queryId, sql } = this.compile()
75 const execute = client.unsafe<Record<string, unknown>>(sql, parameters)
76 if (plugins.length === 0) return execute
77 return Effect.flatMap(execute, (rows) =>
78 Effect.map(
79 Effect.reduce(plugins, { rows: Array.from(rows) } as QueryResult<Record<string, unknown>>, (result, plugin) =>
80 Effect.tryPromise({
81 try: () =>
82 plugin.transformResult({ queryId, result }),
83 catch: (cause) =>
84 new SqlError({ cause })
85 })),
86 (result) =>
87 result.rows
88 ))
89 }
90}
91
92/** @internal */
93function executeCommit(this: Executable) {

Callers 1

effectifyWithSqlFunction · 0.85

Calls 2

mapMethod · 0.65
compileMethod · 0.45

Tested by

no test coverage detected