| 832 | } |
| 833 | |
| 834 | export class ConnectionBuilder<DB> { |
| 835 | readonly #props: ConnectionBuilderProps |
| 836 | |
| 837 | constructor(props: ConnectionBuilderProps) { |
| 838 | this.#props = freeze(props) |
| 839 | } |
| 840 | |
| 841 | async execute<T>( |
| 842 | callback: (db: Kysely<DB>) => Promise<T>, |
| 843 | options?: AbortableOperationOptions, |
| 844 | ): Promise<T> { |
| 845 | return this.#props.executor.provideConnection( |
| 846 | async (connection) => { |
| 847 | const executor = this.#props.executor.withConnectionProvider( |
| 848 | new SingleConnectionProvider(connection), |
| 849 | ) |
| 850 | |
| 851 | const db = new Kysely<DB>({ ...this.#props, executor }) |
| 852 | |
| 853 | return await callback(db) |
| 854 | }, |
| 855 | freeze({ signal: options?.signal }), |
| 856 | ) |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | interface ConnectionBuilderProps extends KyselyProps {} |
| 861 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…