SingleStoreDatabase Class — drizzle-orm Architecture
Architecture documentation for the SingleStoreDatabase class in db.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 17526f8f_740d_de23_63c6_24441259e452["SingleStoreDatabase"] f8321666_9ec2_95b1_a6aa_bc9b6f317f41["db.ts"] 17526f8f_740d_de23_63c6_24441259e452 -->|defined in| f8321666_9ec2_95b1_a6aa_bc9b6f317f41 6bffcf21_7ba3_f026_87ee_6a1b2e0efe1d["constructor()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| 6bffcf21_7ba3_f026_87ee_6a1b2e0efe1d 019d1cda_60e2_f15b_dbab_8c58c0ea2778["$count()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| 019d1cda_60e2_f15b_dbab_8c58c0ea2778 89cc4194_6077_47c3_f92d_2c1f3813ce41["with()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| 89cc4194_6077_47c3_f92d_2c1f3813ce41 f5077ad9_65c7_cce5_f66a_bbeffca09a1f["select()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| f5077ad9_65c7_cce5_f66a_bbeffca09a1f 9d07dccd_921c_3c15_f2e1_ba3b2144efe7["selectDistinct()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| 9d07dccd_921c_3c15_f2e1_ba3b2144efe7 23f13aaa_d82b_791b_5360_56f77f8f9010["update()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| 23f13aaa_d82b_791b_5360_56f77f8f9010 11af9de9_693a_a8e4_d221_357193c41c8b["insert()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| 11af9de9_693a_a8e4_d221_357193c41c8b 28c10f8a_5b1e_cd4b_2608_0e4cdd4a6583["delete()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| 28c10f8a_5b1e_cd4b_2608_0e4cdd4a6583 5454cfdb_7899_e8ff_02c9_d3796a04b225["execute()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| 5454cfdb_7899_e8ff_02c9_d3796a04b225 c51e6ee3_2e15_d4db_5774_758c33563408["transaction()"] 17526f8f_740d_de23_63c6_24441259e452 -->|method| c51e6ee3_2e15_d4db_5774_758c33563408
Relationship Graph
Source Code
drizzle-orm/src/singlestore-core/db.ts lines 31–491
export class SingleStoreDatabase<
TQueryResult extends SingleStoreQueryResultHKT,
TPreparedQueryHKT extends PreparedQueryHKTBase,
TFullSchema extends Record<string, unknown> = {},
TSchema extends TablesRelationalConfig = ExtractTablesWithRelations<TFullSchema>,
> {
static readonly [entityKind]: string = 'SingleStoreDatabase';
declare readonly _: {
readonly schema: TSchema | undefined;
readonly fullSchema: TFullSchema;
readonly tableNamesMap: Record<string, string>;
};
// We are waiting for SingleStore support for `json_array` function
/**@inrernal */
query: unknown;
constructor(
/** @internal */
readonly dialect: SingleStoreDialect,
/** @internal */
readonly session: SingleStoreSession<any, any, any, any>,
schema: RelationalSchemaConfig<TSchema> | undefined,
) {
this._ = schema
? {
schema: schema.schema,
fullSchema: schema.fullSchema as TFullSchema,
tableNamesMap: schema.tableNamesMap,
}
: {
schema: undefined,
fullSchema: {} as TFullSchema,
tableNamesMap: {},
};
this.query = {} as typeof this['query'];
// this.queryNotSupported = true;
// if (this._.schema) {
// for (const [tableName, columns] of Object.entries(this._.schema)) {
// (this.query as SingleStoreDatabase<TQueryResult, TPreparedQueryHKT, Record<string, any>>['query'])[tableName] =
// new RelationalQueryBuilder(
// schema!.fullSchema,
// this._.schema,
// this._.tableNamesMap,
// schema!.fullSchema[tableName] as SingleStoreTable,
// columns,
// dialect,
// session,
// );
// }
// }
this.$cache = { invalidate: async (_params: any) => {} };
}
/**
* Creates a subquery that defines a temporary named result set as a CTE.
*
* It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.
*
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
*
* @param alias The alias for the subquery.
*
* Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.
*
* @example
*
* ```ts
* // Create a subquery with alias 'sq' and use it in the select query
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
*
* const result = await db.with(sq).select().from(sq);
* ```
*
* To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:
*
* ```ts
* // Select an arbitrary SQL value as a field in a CTE and reference it in the main query
* const sq = db.$with('sq').as(db.select({
* name: sql<string>`upper(${users.name})`.as('name'),
Domain
Defined In
Source
Frequently Asked Questions
What is the SingleStoreDatabase class?
SingleStoreDatabase is a class in the drizzle-orm codebase, defined in drizzle-orm/src/singlestore-core/db.ts.
Where is SingleStoreDatabase defined?
SingleStoreDatabase is defined in drizzle-orm/src/singlestore-core/db.ts at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free