Home / Class/ SingleStoreDeleteBase Class — drizzle-orm Architecture

SingleStoreDeleteBase Class — drizzle-orm Architecture

Architecture documentation for the SingleStoreDeleteBase class in delete.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  2fc7ad00_d877_7036_3254_b5230a4dd57b["SingleStoreDeleteBase"]
  a48944c4_ea91_ad5b_6028_9e0244f4093d["delete.ts"]
  2fc7ad00_d877_7036_3254_b5230a4dd57b -->|defined in| a48944c4_ea91_ad5b_6028_9e0244f4093d
  0a8f6c35_9665_9565_399e_29ab9a45620e["constructor()"]
  2fc7ad00_d877_7036_3254_b5230a4dd57b -->|method| 0a8f6c35_9665_9565_399e_29ab9a45620e
  34094e36_e185_d607_fcf3_1d5ba38e6c02["where()"]
  2fc7ad00_d877_7036_3254_b5230a4dd57b -->|method| 34094e36_e185_d607_fcf3_1d5ba38e6c02
  60229686_a2c9_1c40_b21e_cdaacc0759b9["orderBy()"]
  2fc7ad00_d877_7036_3254_b5230a4dd57b -->|method| 60229686_a2c9_1c40_b21e_cdaacc0759b9
  209275d6_b266_6f64_72b6_24d3a0769930["limit()"]
  2fc7ad00_d877_7036_3254_b5230a4dd57b -->|method| 209275d6_b266_6f64_72b6_24d3a0769930
  3501009a_4117_447e_6d96_3952e8aaae6e["getSQL()"]
  2fc7ad00_d877_7036_3254_b5230a4dd57b -->|method| 3501009a_4117_447e_6d96_3952e8aaae6e
  dd376cca_9473_330a_e671_89adfaddb98b["toSQL()"]
  2fc7ad00_d877_7036_3254_b5230a4dd57b -->|method| dd376cca_9473_330a_e671_89adfaddb98b
  6dcf6163_ae40_35be_f54f_55ff91ee2667["prepare()"]
  2fc7ad00_d877_7036_3254_b5230a4dd57b -->|method| 6dcf6163_ae40_35be_f54f_55ff91ee2667
  b9444bf8_d9c6_b658_75b2_7a3cabca0355["$dynamic()"]
  2fc7ad00_d877_7036_3254_b5230a4dd57b -->|method| b9444bf8_d9c6_b658_75b2_7a3cabca0355

Relationship Graph

Source Code

drizzle-orm/src/singlestore-core/query-builders/delete.ts lines 87–215

export class SingleStoreDeleteBase<
	TTable extends SingleStoreTable,
	TQueryResult extends SingleStoreQueryResultHKT,
	// eslint-disable-next-line @typescript-eslint/no-unused-vars
	TPreparedQueryHKT extends PreparedQueryHKTBase,
	TDynamic extends boolean = false,
	// eslint-disable-next-line @typescript-eslint/no-unused-vars
	TExcludedMethods extends string = never,
> extends QueryPromise<SingleStoreQueryResultKind<TQueryResult, never>> implements SQLWrapper {
	static override readonly [entityKind]: string = 'SingleStoreDelete';

	private config: SingleStoreDeleteConfig;

	constructor(
		private table: TTable,
		private session: SingleStoreSession,
		private dialect: SingleStoreDialect,
		withList?: Subquery[],
	) {
		super();
		this.config = { table, withList };
	}

	/**
	 * Adds a `where` clause to the query.
	 *
	 * Calling this method will delete only those rows that fulfill a specified condition.
	 *
	 * See docs: {@link https://orm.drizzle.team/docs/delete}
	 *
	 * @param where the `where` clause.
	 *
	 * @example
	 * You can use conditional operators and `sql function` to filter the rows to be deleted.
	 *
	 * ```ts
	 * // Delete all cars with green color
	 * db.delete(cars).where(eq(cars.color, 'green'));
	 * // or
	 * db.delete(cars).where(sql`${cars.color} = 'green'`)
	 * ```
	 *
	 * You can logically combine conditional operators with `and()` and `or()` operators:
	 *
	 * ```ts
	 * // Delete all BMW cars with a green color
	 * db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
	 *
	 * // Delete all cars with the green or blue color
	 * db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
	 * ```
	 */
	where(where: SQL | undefined): SingleStoreDeleteWithout<this, TDynamic, 'where'> {
		this.config.where = where;
		return this as any;
	}

	orderBy(
		builder: (deleteTable: TTable) => ValueOrArray<SingleStoreColumn | SQL | SQL.Aliased>,
	): SingleStoreDeleteWithout<this, TDynamic, 'orderBy'>;
	orderBy(...columns: (SingleStoreColumn | SQL | SQL.Aliased)[]): SingleStoreDeleteWithout<this, TDynamic, 'orderBy'>;
	orderBy(
		...columns:
			| [(deleteTable: TTable) => ValueOrArray<SingleStoreColumn | SQL | SQL.Aliased>]
			| (SingleStoreColumn | SQL | SQL.Aliased)[]
	): SingleStoreDeleteWithout<this, TDynamic, 'orderBy'> {
		if (typeof columns[0] === 'function') {
			const orderBy = columns[0](
				new Proxy(
					this.config.table[Table.Symbol.Columns],
					new SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),
				) as any,
			);

			const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
			this.config.orderBy = orderByArray;
		} else {
			const orderByArray = columns as (SingleStoreColumn | SQL | SQL.Aliased)[];
			this.config.orderBy = orderByArray;
		}
		return this as any;

Domain

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free