( adapter: SqlDriverAdapter, errorRegistry = new ErrorRegistryInternal(), )
| 86 | // *.bind(adapter) is required to preserve the `this` context of functions whose |
| 87 | // execution is delegated to napi.rs. |
| 88 | export 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. |
no test coverage detected