MCPcopy
hub / github.com/prisma/prisma / createAdapter

Function createAdapter

packages/query-plan-executor/src/logic/adapter.ts:6–20  ·  view source on GitHub ↗
(url: string, supportedFactories: Factory[] = defaultFactories)

Source from the content-addressed store, hash-verified

4import type { SqlDriverAdapter, SqlDriverAdapterFactory, Transaction } from '@prisma/driver-adapter-utils'
5
6export function createAdapter(url: string, supportedFactories: Factory[] = defaultFactories): SqlDriverAdapterFactory {
7 const allSupportedProtocols = supportedFactories.flatMap((factory) => factory.protocols)
8 for (const factory of supportedFactories) {
9 if (factory.protocols.some((protocol) => url.startsWith(`${protocol}://`))) {
10 return wrapFactory(allSupportedProtocols, factory.create(url))
11 }
12 }
13 let urlObj: URL
14 try {
15 urlObj = new URL(url)
16 } catch {
17 throw new Error('Invalid database URL')
18 }
19 throw new Error(`Unsupported protocol in database URL: ${urlObj.protocol}`)
20}
21
22type Factory = {
23 protocols: string[]

Callers 3

adapter.test.tsFile · 0.90
startMethod · 0.90
studio-entry.tsFile · 0.85

Calls 2

wrapFactoryFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected