MCPcopy
hub / github.com/drizzle-team/drizzle-orm / drizzle

Function drizzle

drizzle-orm/src/neon-http/driver.ts:171–226  ·  view source on GitHub ↗
(
	...params: [
		TClient | string,
	] | [
		TClient | string,
		DrizzleConfig<TSchema>,
	] | [
		(
			& DrizzleConfig<TSchema>
			& ({
				connection: string | ({ connectionString: string } & HTTPTransactionOptions<boolean, boolean>);
			} | {
				client: TClient;
			})
		),
	]
)

Source from the content-addressed store, hash-verified

169}
170
171export function drizzle<
172 TSchema extends Record<string, unknown> = Record<string, never>,
173 TClient extends NeonQueryFunction<any, any> = NeonQueryFunction<false, false>,
174>(
175 ...params: [
176 TClient | string,
177 ] | [
178 TClient | string,
179 DrizzleConfig<TSchema>,
180 ] | [
181 (
182 & DrizzleConfig<TSchema>
183 & ({
184 connection: string | ({ connectionString: string } & HTTPTransactionOptions<boolean, boolean>);
185 } | {
186 client: TClient;
187 })
188 ),
189 ]
190): NeonHttpDatabase<TSchema> & {
191 $client: TClient;
192} {
193 if (typeof params[0] === 'string') {
194 const instance = neon(params[0] as string);
195 return construct(instance, params[1]) as any;
196 }
197
198 if (isConfig(params[0])) {
199 const { connection, client, ...drizzleConfig } = params[0] as
200 & {
201 connection?:
202 | ({
203 connectionString: string;
204 } & HTTPTransactionOptions<boolean, boolean>)
205 | string;
206 client?: TClient;
207 }
208 & DrizzleConfig<TSchema>;
209
210 if (client) return construct(client, drizzleConfig);
211
212 if (typeof connection === 'object') {
213 const { connectionString, ...options } = connection;
214
215 const instance = neon(connectionString, options);
216
217 return construct(instance, drizzleConfig) as any;
218 }
219
220 const instance = neon(connection!);
221
222 return construct(instance, drizzleConfig) as any;
223 }
224
225 return construct(params[0] as TClient, params[1] as DrizzleConfig<TSchema> | undefined) as any;
226}
227
228export namespace drizzle {

Callers 4

neon-http.test.mjsFile · 0.90
neon-http.test.tsFile · 0.90

Calls 2

isConfigFunction · 0.90
constructFunction · 0.70

Tested by

no test coverage detected