RelationalQueryBuilder Class — drizzle-orm Architecture
Architecture documentation for the RelationalQueryBuilder class in query.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 65056321_5f30_0069_0b19_be2b8b42e31a["RelationalQueryBuilder"] 1b854fed_016a_a5d6_4aec_b8881a9f16d1["query.ts"] 65056321_5f30_0069_0b19_be2b8b42e31a -->|defined in| 1b854fed_016a_a5d6_4aec_b8881a9f16d1 e2b79bec_664a_4ef1_44f2_965fb33bde1d["constructor()"] 65056321_5f30_0069_0b19_be2b8b42e31a -->|method| e2b79bec_664a_4ef1_44f2_965fb33bde1d 1fa5a9b1_74bb_52dc_fae4_55ee18b2ef5e["findMany()"] 65056321_5f30_0069_0b19_be2b8b42e31a -->|method| 1fa5a9b1_74bb_52dc_fae4_55ee18b2ef5e bab69f9e_95aa_a554_85fe_07e65259dae0["findFirst()"] 65056321_5f30_0069_0b19_be2b8b42e31a -->|method| bab69f9e_95aa_a554_85fe_07e65259dae0
Relationship Graph
Source Code
drizzle-orm/src/sqlite-core/query-builders/query.ts lines 22–96
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,
this.tableConfig,
this.dialect,
this.session,
config ? (config as DBQueryConfig<'many', true>) : {},
'many',
)) as SQLiteRelationalQueryKind<TMode, BuildQueryResult<TSchema, TFields, TConfig>[]>;
}
findFirst<TSelection extends Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(
config?: KnownKeysOnly<TSelection, Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>,
): SQLiteRelationalQueryKind<TMode, BuildQueryResult<TSchema, TFields, TSelection> | undefined> {
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> | undefined), limit: 1 } : { limit: 1 },
'first',
)
: new SQLiteRelationalQuery(
this.fullSchema,
this.schema,
this.tableNamesMap,
this.table,
this.tableConfig,
this.dialect,
this.session,
config ? { ...(config as DBQueryConfig<'many', true> | undefined), limit: 1 } : { limit: 1 },
'first',
)) as SQLiteRelationalQueryKind<TMode, BuildQueryResult<TSchema, TFields, TSelection> | undefined>;
}
}
Domain
Source
Frequently Asked Questions
What is the RelationalQueryBuilder class?
RelationalQueryBuilder is a class in the drizzle-orm codebase, defined in drizzle-orm/src/sqlite-core/query-builders/query.ts.
Where is RelationalQueryBuilder defined?
RelationalQueryBuilder is defined in drizzle-orm/src/sqlite-core/query-builders/query.ts at line 22.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free