Home / Class/ NeonHttpPreparedQuery Class — drizzle-orm Architecture

NeonHttpPreparedQuery Class — drizzle-orm Architecture

Architecture documentation for the NeonHttpPreparedQuery class in session.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  cdc58125_2ef4_435c_f7cb_44b1f97c4c36["NeonHttpPreparedQuery"]
  8c075175_ed31_3ec7_952e_c0a6558abc34["session.ts"]
  cdc58125_2ef4_435c_f7cb_44b1f97c4c36 -->|defined in| 8c075175_ed31_3ec7_952e_c0a6558abc34
  14e6db06_9437_f868_b543_03f0938c9f28["constructor()"]
  cdc58125_2ef4_435c_f7cb_44b1f97c4c36 -->|method| 14e6db06_9437_f868_b543_03f0938c9f28
  f1162366_0075_69be_cc62_f9aa22b2307d["execute()"]
  cdc58125_2ef4_435c_f7cb_44b1f97c4c36 -->|method| f1162366_0075_69be_cc62_f9aa22b2307d
  71e0e369_bc60_d29d_69a1_514039e4dc82["mapResult()"]
  cdc58125_2ef4_435c_f7cb_44b1f97c4c36 -->|method| 71e0e369_bc60_d29d_69a1_514039e4dc82
  5520c856_d229_fbab_deb4_efca82f54db3["all()"]
  cdc58125_2ef4_435c_f7cb_44b1f97c4c36 -->|method| 5520c856_d229_fbab_deb4_efca82f54db3
  2bf74964_389c_8e80_d446_7ababf025db3["values()"]
  cdc58125_2ef4_435c_f7cb_44b1f97c4c36 -->|method| 2bf74964_389c_8e80_d446_7ababf025db3
  c01da418_beda_3a56_5f2e_96919c4a7288["isResponseInArrayMode()"]
  cdc58125_2ef4_435c_f7cb_44b1f97c4c36 -->|method| c01da418_beda_3a56_5f2e_96919c4a7288

Relationship Graph

Source Code

drizzle-orm/src/neon-http/session.ts lines 29–142

export class NeonHttpPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
	static override readonly [entityKind]: string = 'NeonHttpPreparedQuery';
	private clientQuery: (sql: string, params: any[], opts: Record<string, any>) => NeonQueryPromise<any, any>;

	constructor(
		private client: NeonHttpClient,
		query: Query,
		private logger: Logger,
		cache: Cache,
		queryMetadata: {
			type: 'select' | 'update' | 'delete' | 'insert';
			tables: string[];
		} | undefined,
		cacheConfig: WithCacheConfig | undefined,
		private fields: SelectedFieldsOrdered | undefined,
		private _isResponseInArrayMode: boolean,
		private customResultMapper?: (rows: unknown[][]) => T['execute'],
	) {
		super(query, cache, queryMetadata, cacheConfig);
		// `client.query` is for @neondatabase/serverless v1.0.0 and up, where the
		// root query function `client` is only usable as a template function;
		// `client` is a fallback for earlier versions
		this.clientQuery = (client as any).query ?? client as any;
	}

	async execute(placeholderValues: Record<string, unknown> | undefined): Promise<T['execute']>;
	/** @internal */
	async execute(placeholderValues: Record<string, unknown> | undefined, token?: NeonAuthToken): Promise<T['execute']>;
	/** @internal */
	async execute(
		placeholderValues: Record<string, unknown> | undefined = {},
		token: NeonAuthToken | undefined = this.authToken,
	): Promise<T['execute']> {
		const params = fillPlaceholders(this.query.params, placeholderValues);

		this.logger.logQuery(this.query.sql, params);

		const { fields, clientQuery, query, customResultMapper } = this;

		if (!fields && !customResultMapper) {
			return this.queryWithCache(query.sql, params, async () => {
				return clientQuery(
					query.sql,
					params,
					token === undefined
						? rawQueryConfig
						: {
							...rawQueryConfig,
							authToken: token,
						},
				);
			});
		}

		const result = await this.queryWithCache(query.sql, params, async () => {
			return await clientQuery(
				query.sql,
				params,
				token === undefined
					? queryConfig
					: {
						...queryConfig,
						authToken: token,
					},
			);
		});

		return this.mapResult(result);
	}

	override mapResult(result: unknown): unknown {
		if (!this.fields && !this.customResultMapper) {
			return result;
		}

		const rows = (result as FullQueryResults<true>).rows;

		if (this.customResultMapper) {
			return this.customResultMapper(rows);
		}

Domain

Frequently Asked Questions

What is the NeonHttpPreparedQuery class?
NeonHttpPreparedQuery is a class in the drizzle-orm codebase, defined in drizzle-orm/src/neon-http/session.ts.
Where is NeonHttpPreparedQuery defined?
NeonHttpPreparedQuery is defined in drizzle-orm/src/neon-http/session.ts at line 29.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free