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

Method withConnection

packages/sql/src/internal/statement.ts:108–131  ·  view source on GitHub ↗
(
    operation: string,
    f: (
      connection: Connection.Connection,
      sql: string,
      params: ReadonlyArray<unknown>
    ) => Effect.Effect<XA, E>,
    withoutTransform = false
  )

Source from the content-addressed store, hash-verified

106 }
107
108 private withConnection<XA, E>(
109 operation: string,
110 f: (
111 connection: Connection.Connection,
112 sql: string,
113 params: ReadonlyArray<unknown>
114 ) => Effect.Effect<XA, E>,
115 withoutTransform = false
116 ): Effect.Effect<XA, E | Error.SqlError> {
117 return Effect.useSpan(
118 "sql.execute",
119 { kind: "client", captureStackTrace: false },
120 (span) =>
121 withStatement(this, span, (statement) => {
122 const [sql, params] = statement.compile(withoutTransform)
123 for (const [key, value] of this.spanAttributes) {
124 span.attribute(key, value)
125 }
126 span.attribute(ATTR_DB_OPERATION_NAME, operation)
127 span.attribute(ATTR_DB_QUERY_TEXT, sql)
128 return Effect.scoped(Effect.flatMap(this.acquirer, (_) => f(_, sql, params)))
129 })
130 )
131 }
132
133 get withoutTransform(): Effect.Effect<ReadonlyArray<A>, Error.SqlError> {
134 return this.withConnection(

Callers 5

withoutTransformMethod · 0.95
rawMethod · 0.95
valuesMethod · 0.95
unpreparedMethod · 0.95
commitMethod · 0.95

Calls 4

withStatementFunction · 0.85
attributeMethod · 0.65
fFunction · 0.50
compileMethod · 0.45

Tested by

no test coverage detected