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

get() — drizzle-orm Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b77391e5_131a_4f3c_614d_65fffc9bed0b["get()"]
  e722a0dc_424f_e268_b60c_f7637b7e64fb["PreparedQuery"]
  b77391e5_131a_4f3c_614d_65fffc9bed0b -->|defined in| e722a0dc_424f_e268_b60c_f7637b7e64fb
  98d16be4_f92a_9508_7d74_e7b5e2a8d9ce["values()"]
  98d16be4_f92a_9508_7d74_e7b5e2a8d9ce -->|calls| b77391e5_131a_4f3c_614d_65fffc9bed0b
  26fdc4c5_884c_5e0a_0a4a_2a55076a179c["normalizeFieldValue()"]
  b77391e5_131a_4f3c_614d_65fffc9bed0b -->|calls| 26fdc4c5_884c_5e0a_0a4a_2a55076a179c
  style b77391e5_131a_4f3c_614d_65fffc9bed0b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/sql-js/session.ts lines 145–173

	get(placeholderValues?: Record<string, unknown>): T['get'] {
		const stmt = this.client.prepare(this.query.sql);

		const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
		this.logger.logQuery(this.query.sql, params);

		const { fields, joinsNotNullableMap, customResultMapper } = this;
		if (!fields && !customResultMapper) {
			const result = stmt.getAsObject(params as BindParams);

			stmt.free();

			return result;
		}

		const row = stmt.get(params as BindParams);

		stmt.free();

		if (!row || (row.length === 0 && fields!.length > 0)) {
			return undefined;
		}

		if (customResultMapper) {
			return customResultMapper([row], normalizeFieldValue) as T['get'];
		}

		return mapResultRow(fields!, row.map((v) => normalizeFieldValue(v)), joinsNotNullableMap);
	}

Domain

Subdomains

Called By

Frequently Asked Questions

What does get() do?
get() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/sql-js/session.ts.
Where is get() defined?
get() is defined in drizzle-orm/src/sql-js/session.ts at line 145.
What does get() call?
get() calls 1 function(s): normalizeFieldValue.
What calls get()?
get() is called by 1 function(s): values.

Analyze Your Own Codebase

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

Try Supermodel Free