Home / Function/ execute() — drizzle-orm Function Reference

execute() — drizzle-orm Function Reference

Architecture documentation for the execute() function in session.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  564340c4_f5a9_345a_1229_5aa4a12018cc["execute()"]
  16b981b5_3bbc_75b1_a0c4_72a6e30323d2["PreparedQuery"]
  564340c4_f5a9_345a_1229_5aa4a12018cc -->|defined in| 16b981b5_3bbc_75b1_a0c4_72a6e30323d2
  style 564340c4_f5a9_345a_1229_5aa4a12018cc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/pg-proxy/session.ts lines 113–154

	async execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {
		return tracer.startActiveSpan('drizzle.execute', async (span) => {
			const params = fillPlaceholders(this.params, placeholderValues);
			const { fields, client, queryString, joinsNotNullableMap, customResultMapper, logger, typings } = this;

			span?.setAttributes({
				'drizzle.query.text': queryString,
				'drizzle.query.params': JSON.stringify(params),
			});

			logger.logQuery(queryString, params);

			if (!fields && !customResultMapper) {
				return tracer.startActiveSpan('drizzle.driver.execute', async () => {
					const { rows } = await this.queryWithCache(queryString, params, async () => {
						return await client(queryString, params as any[], 'execute', typings);
					});

					return rows;
				});
			}

			const rows = await tracer.startActiveSpan('drizzle.driver.execute', async () => {
				span?.setAttributes({
					'drizzle.query.text': queryString,
					'drizzle.query.params': JSON.stringify(params),
				});

				const { rows } = await this.queryWithCache(queryString, params, async () => {
					return await client(queryString, params as any[], 'all', typings);
				});

				return rows;
			});

			return tracer.startActiveSpan('drizzle.mapResponse', () => {
				return customResultMapper
					? customResultMapper(rows)
					: rows.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));
			});
		});
	}

Domain

Subdomains

Frequently Asked Questions

What does execute() do?
execute() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/pg-proxy/session.ts.
Where is execute() defined?
execute() is defined in drizzle-orm/src/pg-proxy/session.ts at line 113.

Analyze Your Own Codebase

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

Try Supermodel Free