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 89cc4194_6077_47c3_f92d_2c1f3813ce41["with()"] 17526f8f_740d_de23_63c6_24441259e452["SingleStoreDatabase"] 89cc4194_6077_47c3_f92d_2c1f3813ce41 -->|defined in| 17526f8f_740d_de23_63c6_24441259e452 f5077ad9_65c7_cce5_f66a_bbeffca09a1f["select()"] 89cc4194_6077_47c3_f92d_2c1f3813ce41 -->|calls| f5077ad9_65c7_cce5_f66a_bbeffca09a1f 9d07dccd_921c_3c15_f2e1_ba3b2144efe7["selectDistinct()"] 89cc4194_6077_47c3_f92d_2c1f3813ce41 -->|calls| 9d07dccd_921c_3c15_f2e1_ba3b2144efe7 23f13aaa_d82b_791b_5360_56f77f8f9010["update()"] 89cc4194_6077_47c3_f92d_2c1f3813ce41 -->|calls| 23f13aaa_d82b_791b_5360_56f77f8f9010 style 89cc4194_6077_47c3_f92d_2c1f3813ce41 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-orm/src/singlestore-core/db.ts lines 169–314
with(...queries: WithSubquery[]) {
const self = this;
/**
* Creates a select query.
*
* Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.
*
* Use `.from()` method to specify which table to select from.
*
* See docs: {@link https://orm.drizzle.team/docs/select}
*
* @param fields The selection object.
*
* @example
*
* ```ts
* // Select all columns and all rows from the 'cars' table
* const allCars: Car[] = await db.select().from(cars);
*
* // Select specific columns and all rows from the 'cars' table
* const carsIdsAndBrands: { id: number; brand: string }[] = await db.select({
* id: cars.id,
* brand: cars.brand
* })
* .from(cars);
* ```
*
* Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:
*
* ```ts
* // Select specific columns along with expression and all rows from the 'cars' table
* const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({
* id: cars.id,
* lowerBrand: sql<string>`lower(${cars.brand})`,
* })
* .from(cars);
* ```
*/
function select(): SingleStoreSelectBuilder<undefined, TPreparedQueryHKT>;
function select<TSelection extends SelectedFields>(
fields: TSelection,
): SingleStoreSelectBuilder<TSelection, TPreparedQueryHKT>;
function select(fields?: SelectedFields): SingleStoreSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {
return new SingleStoreSelectBuilder({
fields: fields ?? undefined,
session: self.session,
dialect: self.dialect,
withList: queries,
});
}
/**
* Adds `distinct` expression to the select query.
*
* Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.
*
* Use `.from()` method to specify which table to select from.
*
* See docs: {@link https://orm.drizzle.team/docs/select#distinct}
*
* @param fields The selection object.
*
* @example
* ```ts
* // Select all unique rows from the 'cars' table
* await db.selectDistinct()
* .from(cars)
* .orderBy(cars.id, cars.brand, cars.color);
*
* // Select all unique brands from the 'cars' table
* await db.selectDistinct({ brand: cars.brand })
* .from(cars)
* .orderBy(cars.brand);
* ```
*/
function selectDistinct(): SingleStoreSelectBuilder<undefined, TPreparedQueryHKT>;
function selectDistinct<TSelection extends SelectedFields>(
fields: TSelection,
): SingleStoreSelectBuilder<TSelection, TPreparedQueryHKT>;
function selectDistinct(
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does with() do?
with() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/singlestore-core/db.ts.
Where is with() defined?
with() is defined in drizzle-orm/src/singlestore-core/db.ts at line 169.
What does with() call?
with() calls 3 function(s): select, selectDistinct, update.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free