get() — drizzle-orm Function Reference
Architecture documentation for the get() function in selection-proxy.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD a40f58bf_d603_3d63_ca91_0e1365452bad["get()"] dd80b7b3_f33f_d059_9164_4d580deca2d7["SelectionProxyHandler"] a40f58bf_d603_3d63_ca91_0e1365452bad -->|defined in| dd80b7b3_f33f_d059_9164_4d580deca2d7 c020d230_75a2_3639_d9a6_35f2ba7fd5bc["is()"] a40f58bf_d603_3d63_ca91_0e1365452bad -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc e5e56628_cbf5_5125_e1c7_89115dc8ba18["clone()"] a40f58bf_d603_3d63_ca91_0e1365452bad -->|calls| e5e56628_cbf5_5125_e1c7_89115dc8ba18 8e92df7f_f898_3f9a_f9be_9a9823f94a4f["get()"] a40f58bf_d603_3d63_ca91_0e1365452bad -->|calls| 8e92df7f_f898_3f9a_f9be_9a9823f94a4f style a40f58bf_d603_3d63_ca91_0e1365452bad fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-orm/src/selection-proxy.ts lines 47–120
get(subquery: T, prop: string | symbol): any {
if (prop === '_') {
return {
...subquery['_' as keyof typeof subquery],
selectedFields: new Proxy(
(subquery as Subquery)._.selectedFields,
this as ProxyHandler<Record<string, unknown>>,
),
};
}
if (prop === ViewBaseConfig) {
return {
...subquery[ViewBaseConfig as keyof typeof subquery],
selectedFields: new Proxy(
(subquery as View)[ViewBaseConfig].selectedFields,
this as ProxyHandler<Record<string, unknown>>,
),
};
}
if (typeof prop === 'symbol') {
return subquery[prop as keyof typeof subquery];
}
const columns = is(subquery, Subquery)
? subquery._.selectedFields
: is(subquery, View)
? subquery[ViewBaseConfig].selectedFields
: subquery;
const value: unknown = columns[prop as keyof typeof columns];
if (is(value, SQL.Aliased)) {
// Never return the underlying SQL expression for a field previously selected in a subquery
if (this.config.sqlAliasedBehavior === 'sql' && !value.isSelectionField) {
return value.sql;
}
const newValue = value.clone();
newValue.isSelectionField = true;
return newValue;
}
if (is(value, SQL)) {
if (this.config.sqlBehavior === 'sql') {
return value;
}
throw new Error(
`You tried to reference "${prop}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`,
);
}
if (is(value, Column)) {
if (this.config.alias) {
return new Proxy(
value,
new ColumnAliasProxyHandler(
new Proxy(
value.table,
new TableAliasProxyHandler(this.config.alias, this.config.replaceOriginalName ?? false),
),
),
);
}
return value;
}
if (typeof value !== 'object' || value === null) {
return value;
}
return new Proxy(value, new SelectionProxyHandler(this.config));
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does get() do?
get() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/selection-proxy.ts.
Where is get() defined?
get() is defined in drizzle-orm/src/selection-proxy.ts at line 47.
What does get() call?
get() calls 3 function(s): clone, get, is.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free