IndexBuilderOn Class — drizzle-orm Architecture
Architecture documentation for the IndexBuilderOn class in indexes.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 149e5992_d166_053e_4f10_4c8e54d56c14["IndexBuilderOn"] a406baef_d8bd_9bc9_efcd_e7c1450622b0["indexes.ts"] 149e5992_d166_053e_4f10_4c8e54d56c14 -->|defined in| a406baef_d8bd_9bc9_efcd_e7c1450622b0 025fa64c_1f4d_d211_84b5_d79138d9546c["constructor()"] 149e5992_d166_053e_4f10_4c8e54d56c14 -->|method| 025fa64c_1f4d_d211_84b5_d79138d9546c 1bc6938c_24de_a7d3_282f_dd782b7f649b["on()"] 149e5992_d166_053e_4f10_4c8e54d56c14 -->|method| 1bc6938c_24de_a7d3_282f_dd782b7f649b b48a7e0c_36f0_61b4_453e_15923a676328["onOnly()"] 149e5992_d166_053e_4f10_4c8e54d56c14 -->|method| b48a7e0c_36f0_61b4_453e_15923a676328 d8e56065_f82f_ac42_d15a_ce69c32a832b["using()"] 149e5992_d166_053e_4f10_4c8e54d56c14 -->|method| d8e56065_f82f_ac42_d15a_ce69c32a832b
Relationship Graph
Source Code
drizzle-orm/src/pg-core/indexes.ts lines 109–179
export class IndexBuilderOn {
static readonly [entityKind]: string = 'PgIndexBuilderOn';
constructor(private unique: boolean, private name?: string) {}
on(...columns: [Partial<ExtraConfigColumn> | SQL, ...Partial<ExtraConfigColumn | SQL>[]]): IndexBuilder {
return new IndexBuilder(
columns.map((it) => {
if (is(it, SQL)) {
return it;
}
it = it as ExtraConfigColumn;
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
return clonedIndexedColumn;
}),
this.unique,
false,
this.name,
);
}
onOnly(...columns: [Partial<ExtraConfigColumn | SQL>, ...Partial<ExtraConfigColumn | SQL>[]]): IndexBuilder {
return new IndexBuilder(
columns.map((it) => {
if (is(it, SQL)) {
return it;
}
it = it as ExtraConfigColumn;
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);
it.indexConfig = it.defaultConfig;
return clonedIndexedColumn;
}),
this.unique,
true,
this.name,
);
}
/**
* Specify what index method to use. Choices are `btree`, `hash`, `gist`, `spgist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.
*
* If you have the `pg_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
*
* **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
*
* @param method The name of the index method to be used
* @param columns
* @returns
*/
using(
method: PgIndexMethod,
...columns: [Partial<ExtraConfigColumn | SQL>, ...Partial<ExtraConfigColumn | SQL>[]]
): IndexBuilder {
return new IndexBuilder(
columns.map((it) => {
if (is(it, SQL)) {
return it;
}
it = it as ExtraConfigColumn;
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
return clonedIndexedColumn;
}),
this.unique,
true,
this.name,
method,
);
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the IndexBuilderOn class?
IndexBuilderOn is a class in the drizzle-orm codebase, defined in drizzle-orm/src/pg-core/indexes.ts.
Where is IndexBuilderOn defined?
IndexBuilderOn is defined in drizzle-orm/src/pg-core/indexes.ts at line 109.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free