schemaToTypeScript() — drizzle-orm Function Reference
Architecture documentation for the schemaToTypeScript() function in introspect-singlestore.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 81f3f590_bf9d_eaf9_fad5_1c0016bacff9["schemaToTypeScript()"] c6b71380_9588_5d06_58bb_e4dc7e505759["introspect-singlestore.ts"] 81f3f590_bf9d_eaf9_fad5_1c0016bacff9 -->|defined in| c6b71380_9588_5d06_58bb_e4dc7e505759 a84cfaf7_b23a_f5c5_b393_66dbe4bc550e["prepareCasing()"] 81f3f590_bf9d_eaf9_fad5_1c0016bacff9 -->|calls| a84cfaf7_b23a_f5c5_b393_66dbe4bc550e ecce782a_234d_9dbf_0972_914296b25906["createTableColumns()"] 81f3f590_bf9d_eaf9_fad5_1c0016bacff9 -->|calls| ecce782a_234d_9dbf_0972_914296b25906 2dd0696f_8793_9a98_33a7_35929b01e860["createTableIndexes()"] 81f3f590_bf9d_eaf9_fad5_1c0016bacff9 -->|calls| 2dd0696f_8793_9a98_33a7_35929b01e860 face1d96_7511_fae4_3ec9_6ef601fa456d["createTablePKs()"] 81f3f590_bf9d_eaf9_fad5_1c0016bacff9 -->|calls| face1d96_7511_fae4_3ec9_6ef601fa456d 958fa6f7_2aae_0d87_f30b_314b13365f5a["createTableUniques()"] 81f3f590_bf9d_eaf9_fad5_1c0016bacff9 -->|calls| 958fa6f7_2aae_0d87_f30b_314b13365f5a style 81f3f590_bf9d_eaf9_fad5_1c0016bacff9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/introspect-singlestore.ts lines 139–339
export const schemaToTypeScript = (
schema: SingleStoreSchemaInternal,
casing: Casing,
) => {
const withCasing = prepareCasing(casing);
const imports = Object.values(schema.tables).reduce(
(res, it) => {
const idxImports = Object.values(it.indexes).map((idx) => idx.isUnique ? 'uniqueIndex' : 'index');
const pkImports = Object.values(it.compositePrimaryKeys).map(
(it) => 'primaryKey',
);
const uniqueImports = Object.values(it.uniqueConstraints).map(
(it) => 'unique',
);
res.singlestore.push(...idxImports);
res.singlestore.push(...pkImports);
res.singlestore.push(...uniqueImports);
const columnImports = Object.values(it.columns)
.map((col) => {
let patched = importsPatch[col.type] ?? col.type;
patched = patched.startsWith('varchar(') ? 'varchar' : patched;
patched = patched.startsWith('char(') ? 'char' : patched;
patched = patched.startsWith('binary(') ? 'binary' : patched;
patched = patched.startsWith('decimal(') ? 'decimal' : patched;
patched = patched.startsWith('smallint(') ? 'smallint' : patched;
patched = patched.startsWith('enum(') ? 'singlestoreEnum' : patched;
patched = patched.startsWith('datetime(') ? 'datetime' : patched;
patched = patched.startsWith('varbinary(') ? 'varbinary' : patched;
patched = patched.startsWith('int(') ? 'int' : patched;
patched = patched.startsWith('double(') ? 'double' : patched;
patched = patched.startsWith('float(') ? 'float' : patched;
patched = patched.startsWith('int unsigned') ? 'int' : patched;
patched = patched.startsWith('tinyint(') ? 'tinyint' : patched;
patched = patched.startsWith('mediumint(') ? 'mediumint' : patched;
patched = patched.startsWith('bigint(') ? 'bigint' : patched;
patched = patched.startsWith('tinyint unsigned') ? 'tinyint' : patched;
patched = patched.startsWith('smallint unsigned') ? 'smallint' : patched;
patched = patched.startsWith('mediumint unsigned') ? 'mediumint' : patched;
patched = patched.startsWith('bigint unsigned') ? 'bigint' : patched;
return patched;
})
.filter((type) => {
return singlestoreImportsList.has(type);
});
res.singlestore.push(...columnImports);
return res;
},
{ singlestore: [] as string[] },
);
/* Object.values(schema.views).forEach((it) => {
imports.singlestore.push('singlestoreView');
const columnImports = Object.values(it.columns)
.map((col) => {
let patched = importsPatch[col.type] ?? col.type;
patched = patched.startsWith('varchar(') ? 'varchar' : patched;
patched = patched.startsWith('char(') ? 'char' : patched;
patched = patched.startsWith('binary(') ? 'binary' : patched;
patched = patched.startsWith('decimal(') ? 'decimal' : patched;
patched = patched.startsWith('smallint(') ? 'smallint' : patched;
patched = patched.startsWith('enum(') ? 'singlestoreEnum' : patched;
patched = patched.startsWith('datetime(') ? 'datetime' : patched;
patched = patched.startsWith('varbinary(') ? 'varbinary' : patched;
patched = patched.startsWith('int(') ? 'int' : patched;
patched = patched.startsWith('double(') ? 'double' : patched;
patched = patched.startsWith('float(') ? 'float' : patched;
patched = patched.startsWith('int unsigned') ? 'int' : patched;
patched = patched.startsWith('tinyint(') ? 'tinyint' : patched;
patched = patched.startsWith('mediumint(') ? 'mediumint' : patched;
patched = patched.startsWith('bigint(') ? 'bigint' : patched;
patched = patched.startsWith('tinyint unsigned') ? 'tinyint' : patched;
patched = patched.startsWith('smallint unsigned') ? 'smallint' : patched;
patched = patched.startsWith('mediumint unsigned') ? 'mediumint' : patched;
patched = patched.startsWith('bigint unsigned') ? 'bigint' : patched;
return patched;
})
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does schemaToTypeScript() do?
schemaToTypeScript() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/introspect-singlestore.ts.
Where is schemaToTypeScript() defined?
schemaToTypeScript() is defined in drizzle-kit/src/introspect-singlestore.ts at line 139.
What does schemaToTypeScript() call?
schemaToTypeScript() calls 5 function(s): createTableColumns, createTableIndexes, createTablePKs, createTableUniques, prepareCasing.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free