Home / Class/ AwsDataApiPreparedQuery Class — drizzle-orm Architecture

AwsDataApiPreparedQuery Class — drizzle-orm Architecture

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

Entity Profile

Dependency Diagram

graph TD
  faab5053_4366_127b_a6e2_27b2fe6c9635["AwsDataApiPreparedQuery"]
  e8d52f5f_2316_1b4f_9799_7155b57c23ff["session.ts"]
  faab5053_4366_127b_a6e2_27b2fe6c9635 -->|defined in| e8d52f5f_2316_1b4f_9799_7155b57c23ff
  fb91aca1_2260_1070_08a4_6177e167c9b4["constructor()"]
  faab5053_4366_127b_a6e2_27b2fe6c9635 -->|method| fb91aca1_2260_1070_08a4_6177e167c9b4
  bdabd7a9_60b0_77c5_09b6_e9dbcc404675["execute()"]
  faab5053_4366_127b_a6e2_27b2fe6c9635 -->|method| bdabd7a9_60b0_77c5_09b6_e9dbcc404675
  502528d4_d081_be9e_4b57_24bceeaa15fa["all()"]
  faab5053_4366_127b_a6e2_27b2fe6c9635 -->|method| 502528d4_d081_be9e_4b57_24bceeaa15fa
  19e5b6c7_e0b0_fe9a_9ee8_4529ae6d428a["values()"]
  faab5053_4366_127b_a6e2_27b2fe6c9635 -->|method| 19e5b6c7_e0b0_fe9a_9ee8_4529ae6d428a
  4ba78852_6473_ad5f_ab62_4ebe3efcae0c["mapResultRows()"]
  faab5053_4366_127b_a6e2_27b2fe6c9635 -->|method| 4ba78852_6473_ad5f_ab62_4ebe3efcae0c
  c0b9529d_e90c_b162_0686_88e4d9e0aad8["isResponseInArrayMode()"]
  faab5053_4366_127b_a6e2_27b2fe6c9635 -->|method| c0b9529d_e90c_b162_0686_88e4d9e0aad8

Relationship Graph

Source Code

drizzle-orm/src/aws-data-api/pg/session.ts lines 30–149

export class AwsDataApiPreparedQuery<
	T extends PreparedQueryConfig & { values: AwsDataApiPgQueryResult<unknown[]> },
> extends PgPreparedQuery<T> {
	static override readonly [entityKind]: string = 'AwsDataApiPreparedQuery';

	private rawQuery: ExecuteStatementCommand;

	constructor(
		private client: AwsDataApiClient,
		private queryString: string,
		private params: unknown[],
		private typings: QueryTypingsValue[],
		private options: AwsDataApiSessionOptions,
		cache: Cache,
		queryMetadata: {
			type: 'select' | 'update' | 'delete' | 'insert';
			tables: string[];
		} | undefined,
		cacheConfig: WithCacheConfig | undefined,
		private fields: SelectedFieldsOrdered | undefined,
		/** @internal */
		readonly transactionId: string | undefined,
		private _isResponseInArrayMode: boolean,
		private customResultMapper?: (rows: unknown[][]) => T['execute'],
	) {
		super({ sql: queryString, params }, cache, queryMetadata, cacheConfig);
		this.rawQuery = new ExecuteStatementCommand({
			sql: queryString,
			parameters: [],
			secretArn: options.secretArn,
			resourceArn: options.resourceArn,
			database: options.database,
			transactionId,
			includeResultMetadata: !fields && !customResultMapper,
		});
	}

	async execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {
		const { fields, joinsNotNullableMap, customResultMapper } = this;

		const result = await this.values(placeholderValues);
		if (!fields && !customResultMapper) {
			const { columnMetadata, rows } = result;
			if (!columnMetadata) {
				return result;
			}
			const mappedRows = rows.map((sourceRow) => {
				const row: Record<string, unknown> = {};
				for (const [index, value] of sourceRow.entries()) {
					const metadata = columnMetadata[index];
					if (!metadata) {
						throw new Error(
							`Unexpected state: no column metadata found for index ${index}. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,
						);
					}
					if (!metadata.name) {
						throw new Error(
							`Unexpected state: no column name for index ${index} found in the column metadata. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,
						);
					}
					row[metadata.name] = value;
				}
				return row;
			});
			return Object.assign(result, { rows: mappedRows });
		}

		return customResultMapper
			? customResultMapper(result.rows!)
			: result.rows!.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));
	}

	async all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']> {
		const result = await this.execute(placeholderValues);
		if (!this.fields && !this.customResultMapper) {
			return (result as AwsDataApiPgQueryResult<unknown>).rows;
		}
		return result;
	}

	async values(placeholderValues: Record<string, unknown> = {}): Promise<T['values']> {

Domain

Frequently Asked Questions

What is the AwsDataApiPreparedQuery class?
AwsDataApiPreparedQuery is a class in the drizzle-orm codebase, defined in drizzle-orm/src/aws-data-api/pg/session.ts.
Where is AwsDataApiPreparedQuery defined?
AwsDataApiPreparedQuery is defined in drizzle-orm/src/aws-data-api/pg/session.ts at line 30.

Analyze Your Own Codebase

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

Try Supermodel Free