mysqlEnum() — drizzle-orm Function Reference
Architecture documentation for the mysqlEnum() function in enum.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 961804de_d544_ca69_3bff_40d3b1db44ce["mysqlEnum()"] 48523f49_1f0c_29c3_f64b_e37fdb914c83["enum.ts"] 961804de_d544_ca69_3bff_40d3b1db44ce -->|defined in| 48523f49_1f0c_29c3_f64b_e37fdb914c83 style 961804de_d544_ca69_3bff_40d3b1db44ce fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-orm/src/mysql-core/columns/enum.ts lines 110–136
export function mysqlEnum(
a?: string | readonly [string, ...string[]] | [string, ...string[]] | Record<string, string>,
b?: readonly [string, ...string[]] | [string, ...string[]] | Record<string, string>,
): any {
// if name + array or just array - it means we have string union passed
if (typeof a === 'string' && Array.isArray(b) || Array.isArray(a)) {
const name = typeof a === 'string' && a.length > 0 ? a : '';
const values = (typeof a === 'string' ? b : a) ?? [];
if (values.length === 0) {
throw new Error(`You have an empty array for "${name}" enum values`);
}
return new MySqlEnumColumnBuilder(name, values as any);
}
if (typeof a === 'string' && typeof b === 'object' || typeof a === 'object') {
const name = typeof a === 'object' ? '' : a;
const values = typeof a === 'object' ? Object.values(a) : typeof b === 'object' ? Object.values(b) : [];
if (values.length === 0) {
throw new Error(`You have an empty array for "${name}" enum values`);
}
return new MySqlEnumObjectColumnBuilder(name, values as any);
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does mysqlEnum() do?
mysqlEnum() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/mysql-core/columns/enum.ts.
Where is mysqlEnum() defined?
mysqlEnum() is defined in drizzle-orm/src/mysql-core/columns/enum.ts at line 110.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free