columnToSchema() — drizzle-orm Function Reference
Architecture documentation for the columnToSchema() function in column.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD b1c074f5_2da3_d41e_58f2_747e87ddff7d["columnToSchema()"] 03d2f7f9_4592_2641_ed27_5e125e89d737["column.ts"] b1c074f5_2da3_d41e_58f2_747e87ddff7d -->|defined in| 03d2f7f9_4592_2641_ed27_5e125e89d737 ca765c74_0736_6b3c_ef77_d23f23e865ce["handleColumns()"] ca765c74_0736_6b3c_ef77_d23f23e865ce -->|calls| b1c074f5_2da3_d41e_58f2_747e87ddff7d 10989e39_b514_99c0_e36e_be74dac985b7["isWithEnum()"] b1c074f5_2da3_d41e_58f2_747e87ddff7d -->|calls| 10989e39_b514_99c0_e36e_be74dac985b7 cef4925c_d1a6_cdab_3f24_5210220014cb["numberColumnToSchema()"] b1c074f5_2da3_d41e_58f2_747e87ddff7d -->|calls| cef4925c_d1a6_cdab_3f24_5210220014cb 1b5172eb_3663_bdff_6fd7_d145b1ac0540["bigintColumnToSchema()"] b1c074f5_2da3_d41e_58f2_747e87ddff7d -->|calls| 1b5172eb_3663_bdff_6fd7_d145b1ac0540 acbcd7cb_b64c_26cb_b184_e0445479f034["stringColumnToSchema()"] b1c074f5_2da3_d41e_58f2_747e87ddff7d -->|calls| acbcd7cb_b64c_26cb_b184_e0445479f034 style b1c074f5_2da3_d41e_58f2_747e87ddff7d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-arktype/src/column.ts lines 66–126
export function columnToSchema(column: Column): Type {
let schema!: Type;
if (isWithEnum(column)) {
schema = column.enumValues.length ? type.enumerated(...column.enumValues) : type.string;
}
if (!schema) {
// Handle specific types
if (isColumnType<PgGeometry<any> | PgPointTuple<any>>(column, ['PgGeometry', 'PgPointTuple'])) {
schema = type([type.number, type.number]);
} else if (
isColumnType<PgPointObject<any> | PgGeometryObject<any>>(column, ['PgGeometryObject', 'PgPointObject'])
) {
schema = type({
x: type.number,
y: type.number,
});
} else if (isColumnType<PgHalfVector<any> | PgVector<any>>(column, ['PgHalfVector', 'PgVector'])) {
schema = column.dimensions
? type.number.array().exactlyLength(column.dimensions)
: type.number.array();
} else if (isColumnType<PgLineTuple<any>>(column, ['PgLine'])) {
schema = type([type.number, type.number, type.number]);
} else if (isColumnType<PgLineABC<any>>(column, ['PgLineABC'])) {
schema = type({
a: type.number,
b: type.number,
c: type.number,
});
} // Handle other types
else if (isColumnType<PgArray<any, any>>(column, ['PgArray'])) {
const arraySchema = columnToSchema(column.baseColumn).array();
schema = column.size ? arraySchema.exactlyLength(column.size) : arraySchema;
} else if (column.dataType === 'array') {
schema = type.unknown.array();
} else if (column.dataType === 'number') {
schema = numberColumnToSchema(column);
} else if (column.dataType === 'bigint') {
schema = bigintColumnToSchema(column);
} else if (column.dataType === 'boolean') {
schema = type.boolean;
} else if (column.dataType === 'date') {
schema = type.Date;
} else if (column.dataType === 'string') {
schema = stringColumnToSchema(column);
} else if (column.dataType === 'json') {
schema = jsonSchema;
} else if (column.dataType === 'custom') {
schema = type.unknown;
} else if (column.dataType === 'buffer') {
schema = bufferSchema;
}
}
if (!schema) {
schema = type.unknown;
}
return schema;
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does columnToSchema() do?
columnToSchema() is a function in the drizzle-orm codebase, defined in drizzle-arktype/src/column.ts.
Where is columnToSchema() defined?
columnToSchema() is defined in drizzle-arktype/src/column.ts at line 66.
What does columnToSchema() call?
columnToSchema() calls 4 function(s): bigintColumnToSchema, isWithEnum, numberColumnToSchema, stringColumnToSchema.
What calls columnToSchema()?
columnToSchema() is called by 1 function(s): handleColumns.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free