GelSelectBuilder Class — drizzle-orm Architecture
Architecture documentation for the GelSelectBuilder class in select.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD b01e5373_9563_5641_c1d7_a767f8334cb9["GelSelectBuilder"] df5c4433_48d4_a196_2e73_fc27b943fdae["select.ts"] b01e5373_9563_5641_c1d7_a767f8334cb9 -->|defined in| df5c4433_48d4_a196_2e73_fc27b943fdae 9368bba8_0658_2816_734f_8db45b73e4ca["constructor()"] b01e5373_9563_5641_c1d7_a767f8334cb9 -->|method| 9368bba8_0658_2816_734f_8db45b73e4ca f73868f0_bb3a_87f4_99b6_0794de60c602["setToken()"] b01e5373_9563_5641_c1d7_a767f8334cb9 -->|method| f73868f0_bb3a_87f4_99b6_0794de60c602 1b558fe2_759c_cdc3_7424_2ad775f1dfa8["from()"] b01e5373_9563_5641_c1d7_a767f8334cb9 -->|method| 1b558fe2_759c_cdc3_7424_2ad775f1dfa8
Relationship Graph
Source Code
drizzle-orm/src/gel-core/query-builders/select.ts lines 60–145
export class GelSelectBuilder<
TSelection extends SelectedFields | undefined,
TBuilderMode extends 'db' | 'qb' = 'db',
> {
static readonly [entityKind]: string = 'GelSelectBuilder';
private fields: TSelection;
private session: GelSession | undefined;
private dialect: GelDialect;
private withList: Subquery[] = [];
private distinct: boolean | {
on: (GelColumn | SQLWrapper)[];
} | undefined;
constructor(
config: {
fields: TSelection;
session: GelSession | undefined;
dialect: GelDialect;
withList?: Subquery[];
distinct?: boolean | {
on: (GelColumn | SQLWrapper)[];
};
},
) {
this.fields = config.fields;
this.session = config.session;
this.dialect = config.dialect;
if (config.withList) {
this.withList = config.withList;
}
this.distinct = config.distinct;
}
private authToken?: NeonAuthToken;
/** @internal */
setToken(token?: NeonAuthToken) {
this.authToken = token;
return this;
}
/**
* Specify the table, subquery, or other target that you're
* building a select query against.
*
* {@link https://www.postgresql.org/docs/current/sql-select.html#SQL-FROM | Postgres from documentation}
*/
from<TFrom extends GelTable | Subquery | GelViewBase | SQL>(
source: TFrom,
): CreateGelSelectFromBuilderMode<
TBuilderMode,
GetSelectTableName<TFrom>,
TSelection extends undefined ? GetSelectTableSelection<TFrom> : TSelection,
TSelection extends undefined ? 'single' : 'partial'
> {
const isPartialSelect = !!this.fields;
let fields: SelectedFields;
if (this.fields) {
fields = this.fields;
} else if (is(source, Subquery)) {
// This is required to use the proxy handler to get the correct field values from the subquery
fields = Object.fromEntries(
Object.keys(source._.selectedFields).map((
key,
) => [key, source[key as unknown as keyof typeof source] as unknown as SelectedFields[string]]),
);
} else if (is(source, GelViewBase)) {
fields = source[ViewBaseConfig].selectedFields as SelectedFields;
} else if (is(source, SQL)) {
fields = {};
} else {
fields = getTableColumns<GelTable>(source);
}
return new GelSelectBase({
table: source,
fields,
isPartialSelect,
session: this.session,
dialect: this.dialect,
Domain
Source
Frequently Asked Questions
What is the GelSelectBuilder class?
GelSelectBuilder is a class in the drizzle-orm codebase, defined in drizzle-orm/src/gel-core/query-builders/select.ts.
Where is GelSelectBuilder defined?
GelSelectBuilder is defined in drizzle-orm/src/gel-core/query-builders/select.ts at line 60.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free