MCPcopy
hub / github.com/prisma/prisma / bindAdapter

Function bindAdapter

packages/driver-adapter-utils/src/binder.ts:88–111  ·  view source on GitHub ↗
(
  adapter: SqlDriverAdapter,
  errorRegistry = new ErrorRegistryInternal(),
)

Source from the content-addressed store, hash-verified

86// *.bind(adapter) is required to preserve the `this` context of functions whose
87// execution is delegated to napi.rs.
88export const bindAdapter = (
89 adapter: SqlDriverAdapter,
90 errorRegistry = new ErrorRegistryInternal(),
91): ErrorCapturingSqlDriverAdapter => {
92 const boundAdapter: ErrorCapturingSqlDriverAdapter = {
93 adapterName: adapter.adapterName,
94 errorRegistry,
95 queryRaw: wrapAsync(errorRegistry, adapter.queryRaw.bind(adapter)),
96 executeRaw: wrapAsync(errorRegistry, adapter.executeRaw.bind(adapter)),
97 executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
98 dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
99 provider: adapter.provider,
100 startTransaction: async (...args) => {
101 const ctx = await wrapAsync(errorRegistry, adapter.startTransaction.bind(adapter))(...args)
102 return ctx.map((ctx) => bindTransaction(errorRegistry, ctx))
103 },
104 }
105
106 if (adapter.getConnectionInfo) {
107 boundAdapter.getConnectionInfo = wrapSync(errorRegistry, adapter.getConnectionInfo.bind(adapter))
108 }
109
110 return boundAdapter
111}
112
113// *.bind(transaction) is required to preserve the `this` context of functions whose
114// execution is delegated to napi.rs.

Callers 2

bindSqlAdapterFactoryFunction · 0.85

Calls 3

wrapAsyncFunction · 0.85
bindTransactionFunction · 0.85
wrapSyncFunction · 0.85

Tested by

no test coverage detected