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

query() — drizzle-orm Function Reference

Architecture documentation for the query() function in mysql-proxy.test.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  94e5d831_42a0_71bd_829a_0c755b04cd61["query()"]
  75656cb7_cdf7_c139_423d_32a1503bf89d["ServerSimulator"]
  94e5d831_42a0_71bd_829a_0c755b04cd61 -->|defined in| 75656cb7_cdf7_c139_423d_32a1503bf89d
  8f85f40c_ece2_3507_0e52_667752a58627["migrations()"]
  8f85f40c_ece2_3507_0e52_667752a58627 -->|calls| 94e5d831_42a0_71bd_829a_0c755b04cd61
  style 94e5d831_42a0_71bd_829a_0c755b04cd61 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

integration-tests/tests/mysql/mysql-proxy.test.ts lines 15–54

	async query(sql: string, params: any[], method: 'all' | 'execute') {
		if (method === 'all') {
			try {
				const result = await this.db.query({
					sql,
					values: params,
					rowsAsArray: true,
					typeCast: function(field: any, next: any) {
						if (field.type === 'TIMESTAMP' || field.type === 'DATETIME' || field.type === 'DATE') {
							return field.string();
						}
						return next();
					},
				});

				return { data: result[0] as any };
			} catch (e: any) {
				return { error: e };
			}
		} else if (method === 'execute') {
			try {
				const result = await this.db.query({
					sql,
					values: params,
					typeCast: function(field: any, next: any) {
						if (field.type === 'TIMESTAMP' || field.type === 'DATETIME' || field.type === 'DATE') {
							return field.string();
						}
						return next();
					},
				});

				return { data: result as any };
			} catch (e: any) {
				return { error: e };
			}
		} else {
			return { error: 'Unknown method value' };
		}
	}

Domain

Subdomains

Called By

Frequently Asked Questions

What does query() do?
query() is a function in the drizzle-orm codebase, defined in integration-tests/tests/mysql/mysql-proxy.test.ts.
Where is query() defined?
query() is defined in integration-tests/tests/mysql/mysql-proxy.test.ts at line 15.
What calls query()?
query() is called by 1 function(s): migrations.

Analyze Your Own Codebase

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

Try Supermodel Free