Home / File/ query.ts — drizzle-orm Source File

query.ts — drizzle-orm Source File

Architecture documentation for query.ts, a typescript file in the drizzle-orm codebase. 9 imports, 1 dependents.

File typescript DrizzleORM SQLDialects 9 imports 1 dependents 3 classes

Entity Profile

Dependency Diagram

graph LR
  1b854fed_016a_a5d6_4aec_b8881a9f16d1["query.ts"]
  209e34fa_8ae1_5a1a_23cb_e4720fd5b915["dialect.ts"]
  1b854fed_016a_a5d6_4aec_b8881a9f16d1 --> 209e34fa_8ae1_5a1a_23cb_e4720fd5b915
  0246584b_d63a_06ad_4a46_dd97d5212ea8["session.ts"]
  1b854fed_016a_a5d6_4aec_b8881a9f16d1 --> 0246584b_d63a_06ad_4a46_dd97d5212ea8
  64ae061d_ed9a_c5f9_235a_3f31995a8d54["table.ts"]
  1b854fed_016a_a5d6_4aec_b8881a9f16d1 --> 64ae061d_ed9a_c5f9_235a_3f31995a8d54
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  1b854fed_016a_a5d6_4aec_b8881a9f16d1 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  6acf5c54_62a7_1da1_984a_7374cbb9983e["query-promise.ts"]
  1b854fed_016a_a5d6_4aec_b8881a9f16d1 --> 6acf5c54_62a7_1da1_984a_7374cbb9983e
  e4d6a0ab_9aa2_13a6_a2f1_58d94314c3f2["relations.ts"]
  1b854fed_016a_a5d6_4aec_b8881a9f16d1 --> e4d6a0ab_9aa2_13a6_a2f1_58d94314c3f2
  05d1039e_d7d0_0fa1_6f52_956655638080["runnable-query.ts"]
  1b854fed_016a_a5d6_4aec_b8881a9f16d1 --> 05d1039e_d7d0_0fa1_6f52_956655638080
  be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd["sql.ts"]
  1b854fed_016a_a5d6_4aec_b8881a9f16d1 --> be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  1b854fed_016a_a5d6_4aec_b8881a9f16d1 --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  e9188303_2815_1371_46b3_eb6061e52537["db.ts"]
  e9188303_2815_1371_46b3_eb6061e52537 --> 1b854fed_016a_a5d6_4aec_b8881a9f16d1
  style 1b854fed_016a_a5d6_4aec_b8881a9f16d1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { entityKind } from '~/entity.ts';
import { QueryPromise } from '~/query-promise.ts';
import {
	type BuildQueryResult,
	type BuildRelationalQueryResult,
	type DBQueryConfig,
	mapRelationalRow,
	type TableRelationalConfig,
	type TablesRelationalConfig,
} from '~/relations.ts';
import type { RunnableQuery } from '~/runnable-query.ts';
import type { Query, QueryWithTypings, SQL, SQLWrapper } from '~/sql/sql.ts';
import type { KnownKeysOnly } from '~/utils.ts';
import type { SQLiteDialect } from '../dialect.ts';
import type { PreparedQueryConfig, SQLitePreparedQuery, SQLiteSession } from '../session.ts';
import type { SQLiteTable } from '../table.ts';

export type SQLiteRelationalQueryKind<TMode extends 'sync' | 'async', TResult> = TMode extends 'async'
	? SQLiteRelationalQuery<TMode, TResult>
	: SQLiteSyncRelationalQuery<TResult>;

export class RelationalQueryBuilder<
	TMode extends 'sync' | 'async',
	TFullSchema extends Record<string, unknown>,
	TSchema extends TablesRelationalConfig,
	TFields extends TableRelationalConfig,
> {
	static readonly [entityKind]: string = 'SQLiteAsyncRelationalQueryBuilder';

	constructor(
		protected mode: TMode,
		protected fullSchema: Record<string, unknown>,
		protected schema: TSchema,
		protected tableNamesMap: Record<string, string>,
		protected table: SQLiteTable,
		protected tableConfig: TableRelationalConfig,
		protected dialect: SQLiteDialect,
		protected session: SQLiteSession<'async', unknown, TFullSchema, TSchema>,
	) {}

	findMany<TConfig extends DBQueryConfig<'many', true, TSchema, TFields>>(
		config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', true, TSchema, TFields>>,
	): SQLiteRelationalQueryKind<TMode, BuildQueryResult<TSchema, TFields, TConfig>[]> {
		return (this.mode === 'sync'
			? new SQLiteSyncRelationalQuery(
				this.fullSchema,
				this.schema,
				this.tableNamesMap,
				this.table,
				this.tableConfig,
				this.dialect,
				this.session,
				config ? (config as DBQueryConfig<'many', true>) : {},
				'many',
			)
			: new SQLiteRelationalQuery(
				this.fullSchema,
				this.schema,
				this.tableNamesMap,
				this.table,
// ... (148 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does query.ts do?
query.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, SQLDialects subdomain.
What does query.ts depend on?
query.ts imports 9 module(s): dialect.ts, entity.ts, query-promise.ts, relations.ts, runnable-query.ts, session.ts, sql.ts, table.ts, and 1 more.
What files import query.ts?
query.ts is imported by 1 file(s): db.ts.
Where is query.ts in the architecture?
query.ts is located at drizzle-orm/src/sqlite-core/query-builders/query.ts (domain: DrizzleORM, subdomain: SQLDialects, directory: drizzle-orm/src/sqlite-core/query-builders).

Analyze Your Own Codebase

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

Try Supermodel Free