indexes.ts — drizzle-orm Source File
Architecture documentation for indexes.ts, a typescript file in the drizzle-orm codebase. 4 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR a5a9f725_34b6_8a98_a70a_5e7133d7ec60["indexes.ts"] e383fa18_3db6_3f2c_0ac0_30b5ced54ad6["index.ts"] a5a9f725_34b6_8a98_a70a_5e7133d7ec60 --> e383fa18_3db6_3f2c_0ac0_30b5ced54ad6 62c695d3_7eff_3822_db70_ce6b25ccdb04["table.ts"] a5a9f725_34b6_8a98_a70a_5e7133d7ec60 --> 62c695d3_7eff_3822_db70_ce6b25ccdb04 27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"] a5a9f725_34b6_8a98_a70a_5e7133d7ec60 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426 be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd["sql.ts"] a5a9f725_34b6_8a98_a70a_5e7133d7ec60 --> be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd beabf465_fa9a_6d7b_17f0_933ae73209d6["select.ts"] beabf465_fa9a_6d7b_17f0_933ae73209d6 --> a5a9f725_34b6_8a98_a70a_5e7133d7ec60 62c695d3_7eff_3822_db70_ce6b25ccdb04["table.ts"] 62c695d3_7eff_3822_db70_ce6b25ccdb04 --> a5a9f725_34b6_8a98_a70a_5e7133d7ec60 af63b8b3_1221_118f_75ac_f0b56c078499["utils.ts"] af63b8b3_1221_118f_75ac_f0b56c078499 --> a5a9f725_34b6_8a98_a70a_5e7133d7ec60 style a5a9f725_34b6_8a98_a70a_5e7133d7ec60 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { entityKind } from '~/entity.ts';
import type { SQL } from '~/sql/sql.ts';
import type { AnyMySqlColumn, MySqlColumn } from './columns/index.ts';
import type { MySqlTable } from './table.ts';
interface IndexConfig {
name: string;
columns: IndexColumn[];
/**
* If true, the index will be created as `create unique index` instead of `create index`.
*/
unique?: boolean;
/**
* If set, the index will be created as `create index ... using { 'btree' | 'hash' }`.
*/
using?: 'btree' | 'hash';
/**
* If set, the index will be created as `create index ... algorithm { 'default' | 'inplace' | 'copy' }`.
*/
algorithm?: 'default' | 'inplace' | 'copy';
/**
* If set, adds locks to the index creation.
*/
lock?: 'default' | 'none' | 'shared' | 'exclusive';
}
export type IndexColumn = MySqlColumn | SQL;
export class IndexBuilderOn {
static readonly [entityKind]: string = 'MySqlIndexBuilderOn';
constructor(private name: string, private unique: boolean) {}
on(...columns: [IndexColumn, ...IndexColumn[]]): IndexBuilder {
return new IndexBuilder(this.name, columns, this.unique);
}
}
export interface AnyIndexBuilder {
build(table: MySqlTable): Index;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface IndexBuilder extends AnyIndexBuilder {}
export class IndexBuilder implements AnyIndexBuilder {
static readonly [entityKind]: string = 'MySqlIndexBuilder';
/** @internal */
config: IndexConfig;
constructor(name: string, columns: IndexColumn[], unique: boolean) {
this.config = {
name,
columns,
unique,
};
}
using(using: IndexConfig['using']): this {
this.config.using = using;
return this;
}
algorithm(algorithm: IndexConfig['algorithm']): this {
this.config.algorithm = algorithm;
return this;
}
lock(lock: IndexConfig['lock']): this {
this.config.lock = lock;
return this;
}
/** @internal */
build(table: MySqlTable): Index {
return new Index(this.config, table);
}
}
export class Index {
static readonly [entityKind]: string = 'MySqlIndex';
readonly config: IndexConfig & { table: MySqlTable };
constructor(config: IndexConfig, table: MySqlTable) {
this.config = { ...config, table };
}
}
export type GetColumnsTableName<TColumns> = TColumns extends
AnyMySqlColumn<{ tableName: infer TTableName extends string }> | AnyMySqlColumn<
{ tableName: infer TTableName extends string }
>[] ? TTableName
: never;
export function index(name: string): IndexBuilderOn {
return new IndexBuilderOn(name, false);
}
export function uniqueIndex(name: string): IndexBuilderOn {
return new IndexBuilderOn(name, true);
}
Domain
Subdomains
Classes
Imported By
Source
Frequently Asked Questions
What does indexes.ts do?
indexes.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, SQLDialects subdomain.
What does indexes.ts depend on?
indexes.ts imports 4 module(s): entity.ts, index.ts, sql.ts, table.ts.
What files import indexes.ts?
indexes.ts is imported by 3 file(s): select.ts, table.ts, utils.ts.
Where is indexes.ts in the architecture?
indexes.ts is located at drizzle-orm/src/mysql-core/indexes.ts (domain: DrizzleORM, subdomain: SQLDialects, directory: drizzle-orm/src/mysql-core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free