SQLiteRelationalQuery Class — drizzle-orm Architecture
Architecture documentation for the SQLiteRelationalQuery class in query.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 765d2955_5987_484a_db1f_a5727e426ad2["SQLiteRelationalQuery"] 1b854fed_016a_a5d6_4aec_b8881a9f16d1["query.ts"] 765d2955_5987_484a_db1f_a5727e426ad2 -->|defined in| 1b854fed_016a_a5d6_4aec_b8881a9f16d1 44355374_1821_383d_ce03_9474839576f7["constructor()"] 765d2955_5987_484a_db1f_a5727e426ad2 -->|method| 44355374_1821_383d_ce03_9474839576f7 99e67617_129f_d3c8_e928_0b7a61b52ed9["getSQL()"] 765d2955_5987_484a_db1f_a5727e426ad2 -->|method| 99e67617_129f_d3c8_e928_0b7a61b52ed9 a62147a3_7eb0_2b31_787d_da8177a40ee4["_prepare()"] 765d2955_5987_484a_db1f_a5727e426ad2 -->|method| a62147a3_7eb0_2b31_787d_da8177a40ee4 4549f4ce_6140_df00_a3f7_c43c0a84d21d["prepare()"] 765d2955_5987_484a_db1f_a5727e426ad2 -->|method| 4549f4ce_6140_df00_a3f7_c43c0a84d21d d1659fa8_c51b_4fc2_d1e7_68b922ae9ab7["_toSQL()"] 765d2955_5987_484a_db1f_a5727e426ad2 -->|method| d1659fa8_c51b_4fc2_d1e7_68b922ae9ab7 7e68a431_355c_eccd_f7ec_9894fa553a7f["toSQL()"] 765d2955_5987_484a_db1f_a5727e426ad2 -->|method| 7e68a431_355c_eccd_f7ec_9894fa553a7f 64fbd690_3de5_c1f9_8363_b32c729c0fb2["executeRaw()"] 765d2955_5987_484a_db1f_a5727e426ad2 -->|method| 64fbd690_3de5_c1f9_8363_b32c729c0fb2 1e01498b_4b54_d881_60b2_41a635d4d78c["execute()"] 765d2955_5987_484a_db1f_a5727e426ad2 -->|method| 1e01498b_4b54_d881_60b2_41a635d4d78c
Relationship Graph
Source Code
drizzle-orm/src/sqlite-core/query-builders/query.ts lines 98–199
export class SQLiteRelationalQuery<TType extends 'sync' | 'async', TResult> extends QueryPromise<TResult>
implements RunnableQuery<TResult, 'sqlite'>, SQLWrapper
{
static override readonly [entityKind]: string = 'SQLiteAsyncRelationalQuery';
declare readonly _: {
readonly dialect: 'sqlite';
readonly type: TType;
readonly result: TResult;
};
/** @internal */
mode: 'many' | 'first';
constructor(
private fullSchema: Record<string, unknown>,
private schema: TablesRelationalConfig,
private tableNamesMap: Record<string, string>,
/** @internal */
public table: SQLiteTable,
private tableConfig: TableRelationalConfig,
private dialect: SQLiteDialect,
private session: SQLiteSession<'sync' | 'async', unknown, Record<string, unknown>, TablesRelationalConfig>,
private config: DBQueryConfig<'many', true> | true,
mode: 'many' | 'first',
) {
super();
this.mode = mode;
}
/** @internal */
getSQL(): SQL {
return this.dialect.buildRelationalQuery({
fullSchema: this.fullSchema,
schema: this.schema,
tableNamesMap: this.tableNamesMap,
table: this.table,
tableConfig: this.tableConfig,
queryConfig: this.config,
tableAlias: this.tableConfig.tsName,
}).sql as SQL;
}
/** @internal */
_prepare(
isOneTimeQuery = false,
): SQLitePreparedQuery<PreparedQueryConfig & { type: TType; all: TResult; get: TResult; execute: TResult }> {
const { query, builtQuery } = this._toSQL();
return this.session[isOneTimeQuery ? 'prepareOneTimeQuery' : 'prepareQuery'](
builtQuery,
undefined,
this.mode === 'first' ? 'get' : 'all',
true,
(rawRows, mapColumnValue) => {
const rows = rawRows.map((row) =>
mapRelationalRow(this.schema, this.tableConfig, row, query.selection, mapColumnValue)
);
if (this.mode === 'first') {
return rows[0] as TResult;
}
return rows as TResult;
},
) as SQLitePreparedQuery<PreparedQueryConfig & { type: TType; all: TResult; get: TResult; execute: TResult }>;
}
prepare(): SQLitePreparedQuery<PreparedQueryConfig & { type: TType; all: TResult; get: TResult; execute: TResult }> {
return this._prepare(false);
}
private _toSQL(): { query: BuildRelationalQueryResult; builtQuery: QueryWithTypings } {
const query = this.dialect.buildRelationalQuery({
fullSchema: this.fullSchema,
schema: this.schema,
tableNamesMap: this.tableNamesMap,
table: this.table,
tableConfig: this.tableConfig,
queryConfig: this.config,
tableAlias: this.tableConfig.tsName,
});
Domain
Source
Frequently Asked Questions
What is the SQLiteRelationalQuery class?
SQLiteRelationalQuery is a class in the drizzle-orm codebase, defined in drizzle-orm/src/sqlite-core/query-builders/query.ts.
Where is SQLiteRelationalQuery defined?
SQLiteRelationalQuery is defined in drizzle-orm/src/sqlite-core/query-builders/query.ts at line 98.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free