CasingCache Class — drizzle-orm Architecture
Architecture documentation for the CasingCache class in casing.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 5c81fdb3_ce13_bae3_7b2d_234662703206["CasingCache"] f75147d3_9ada_e5d8_9b05_204b10aba05f["casing.ts"] 5c81fdb3_ce13_bae3_7b2d_234662703206 -->|defined in| f75147d3_9ada_e5d8_9b05_204b10aba05f 8cf84043_0431_8086_5ffa_203200919ccc["constructor()"] 5c81fdb3_ce13_bae3_7b2d_234662703206 -->|method| 8cf84043_0431_8086_5ffa_203200919ccc 28c82d92_75b9_f8d4_89a3_9efb6eef87e6["getColumnCasing()"] 5c81fdb3_ce13_bae3_7b2d_234662703206 -->|method| 28c82d92_75b9_f8d4_89a3_9efb6eef87e6 7e5328d2_b26d_89a1_f1f5_24c63e5ea74a["cacheTable()"] 5c81fdb3_ce13_bae3_7b2d_234662703206 -->|method| 7e5328d2_b26d_89a1_f1f5_24c63e5ea74a be481b57_0a9d_4389_7247_4b43015e532e["clearCache()"] 5c81fdb3_ce13_bae3_7b2d_234662703206 -->|method| be481b57_0a9d_4389_7247_4b43015e532e
Relationship Graph
Source Code
drizzle-orm/src/casing.ts lines 29–76
export class CasingCache {
static readonly [entityKind]: string = 'CasingCache';
/** @internal */
cache: Record<string, string> = {};
private cachedTables: Record<string, true> = {};
private convert: (input: string) => string;
constructor(casing?: Casing) {
this.convert = casing === 'snake_case'
? toSnakeCase
: casing === 'camelCase'
? toCamelCase
: noopCase;
}
getColumnCasing(column: Column): string {
if (!column.keyAsName) return column.name;
const schema = column.table[Table.Symbol.Schema] ?? 'public';
const tableName = column.table[Table.Symbol.OriginalName];
const key = `${schema}.${tableName}.${column.name}`;
if (!this.cache[key]) {
this.cacheTable(column.table);
}
return this.cache[key]!;
}
private cacheTable(table: Table) {
const schema = table[Table.Symbol.Schema] ?? 'public';
const tableName = table[Table.Symbol.OriginalName];
const tableKey = `${schema}.${tableName}`;
if (!this.cachedTables[tableKey]) {
for (const column of Object.values(table[Table.Symbol.Columns])) {
const columnKey = `${tableKey}.${column.name}`;
this.cache[columnKey] = this.convert(column.name);
}
this.cachedTables[tableKey] = true;
}
}
clearCache() {
this.cache = {};
this.cachedTables = {};
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the CasingCache class?
CasingCache is a class in the drizzle-orm codebase, defined in drizzle-orm/src/casing.ts.
Where is CasingCache defined?
CasingCache is defined in drizzle-orm/src/casing.ts at line 29.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free