$with() — drizzle-orm Function Reference
Architecture documentation for the $with() function in db.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD de5b0f24_d478_a1db_8df5_4c89acbc2b82["$with()"] 2d57d0b7_4a77_af8e_8027_62a4fb11f803["GelDatabase"] de5b0f24_d478_a1db_8df5_4c89acbc2b82 -->|defined in| 2d57d0b7_4a77_af8e_8027_62a4fb11f803 d2020b13_06e0_e575_3703_4a78bd11a479["withReplicas()"] d2020b13_06e0_e575_3703_4a78bd11a479 -->|calls| de5b0f24_d478_a1db_8df5_4c89acbc2b82 493f8637_2de0_c669_8a0a_80ddd460f4aa["getSQL()"] de5b0f24_d478_a1db_8df5_4c89acbc2b82 -->|calls| 493f8637_2de0_c669_8a0a_80ddd460f4aa style de5b0f24_d478_a1db_8df5_4c89acbc2b82 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-orm/src/gel-core/db.ts lines 117–133
$with<TAlias extends string>(alias: TAlias) {
const self = this;
return {
as<TSelection extends ColumnsSelection>(
qb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>),
): WithSubqueryWithSelection<TSelection, TAlias> {
if (typeof qb === 'function') {
qb = qb(new QueryBuilder(self.dialect));
}
return new Proxy(
new WithSubquery(qb.getSQL(), qb.getSelectedFields() as SelectedFields, alias, true),
new SelectionProxyHandler({ alias, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),
) as WithSubqueryWithSelection<TSelection, TAlias>;
},
};
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does $with() do?
$with() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/gel-core/db.ts.
Where is $with() defined?
$with() is defined in drizzle-orm/src/gel-core/db.ts at line 117.
What does $with() call?
$with() calls 1 function(s): getSQL.
What calls $with()?
$with() is called by 1 function(s): withReplicas.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free