Home / Class/ SingleStoreSelectBase Class — drizzle-orm Architecture

SingleStoreSelectBase Class — drizzle-orm Architecture

Architecture documentation for the SingleStoreSelectBase class in select.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  cdd85ca1_d008_8d04_acfa_142e3876d2e5["SingleStoreSelectBase"]
  eddab78d_59a6_c51b_6a1e_6cd2989d2bc3["select.ts"]
  cdd85ca1_d008_8d04_acfa_142e3876d2e5 -->|defined in| eddab78d_59a6_c51b_6a1e_6cd2989d2bc3
  9252c292_7b09_3c3f_2866_6a8833bba892["prepare()"]
  cdd85ca1_d008_8d04_acfa_142e3876d2e5 -->|method| 9252c292_7b09_3c3f_2866_6a8833bba892
  b591d1f1_b4d7_ff99_e591_ea0645b39f59["$withCache()"]
  cdd85ca1_d008_8d04_acfa_142e3876d2e5 -->|method| b591d1f1_b4d7_ff99_e591_ea0645b39f59

Relationship Graph

Source Code

drizzle-orm/src/singlestore-core/query-builders/select.ts lines 965–1027

export class SingleStoreSelectBase<
	TTableName extends string | undefined,
	TSelection,
	TSelectMode extends SelectMode,
	TPreparedQueryHKT extends PreparedQueryHKTBase,
	TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>
		: {},
	TDynamic extends boolean = false,
	TExcludedMethods extends string = never,
	TResult = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],
	TSelectedFields = BuildSubquerySelection<TSelection, TNullabilityMap>,
> extends SingleStoreSelectQueryBuilderBase<
	SingleStoreSelectHKT,
	TTableName,
	TSelection,
	TSelectMode,
	TPreparedQueryHKT,
	TNullabilityMap,
	TDynamic,
	TExcludedMethods,
	TResult,
	TSelectedFields
> {
	static override readonly [entityKind]: string = 'SingleStoreSelect';

	prepare(): SingleStoreSelectPrepare<this> {
		if (!this.session) {
			throw new Error('Cannot execute a query on a query builder. Please use a database instance instead.');
		}
		const fieldsList = orderSelectedFields<SingleStoreColumn>(this.config.fields);
		const query = this.session.prepareQuery<
			SingleStorePreparedQueryConfig & { execute: SelectResult<TSelection, TSelectMode, TNullabilityMap>[] },
			TPreparedQueryHKT
		>(this.dialect.sqlToQuery(this.getSQL()), fieldsList, undefined, undefined, undefined, {
			type: 'select',
			tables: [...this.usedTables],
		}, this.cacheConfig);
		query.joinsNotNullableMap = this.joinsNotNullableMap;
		return query as SingleStoreSelectPrepare<this>;
	}

	$withCache(config?: { config?: CacheConfig; tag?: string; autoInvalidate?: boolean } | false) {
		this.cacheConfig = config === undefined
			? { config: {}, enable: true, autoInvalidate: true }
			: config === false
			? { enable: false }
			: { enable: true, autoInvalidate: true, ...config };
		return this;
	}

	execute = ((placeholderValues) => {
		return this.prepare().execute(placeholderValues);
	}) as ReturnType<this['prepare']>['execute'];

	private createIterator = (): ReturnType<this['prepare']>['iterator'] => {
		const self = this;
		return async function*(placeholderValues) {
			yield* self.prepare().iterator(placeholderValues);
		};
	};

	iterator = this.createIterator();
}

Domain

Frequently Asked Questions

What is the SingleStoreSelectBase class?
SingleStoreSelectBase is a class in the drizzle-orm codebase, defined in drizzle-orm/src/singlestore-core/query-builders/select.ts.
Where is SingleStoreSelectBase defined?
SingleStoreSelectBase is defined in drizzle-orm/src/singlestore-core/query-builders/select.ts at line 965.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free