PgNumeric Class — drizzle-orm Architecture
Architecture documentation for the PgNumeric class in numeric.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD af6d71cb_a439_6e4e_54be_763b1b436e4a["PgNumeric"] b02d9686_b68f_1cdd_74bf_e7c79bb754fb["numeric.ts"] af6d71cb_a439_6e4e_54be_763b1b436e4a -->|defined in| b02d9686_b68f_1cdd_74bf_e7c79bb754fb b20d8c19_2559_75e5_38da_179f2daff259["constructor()"] af6d71cb_a439_6e4e_54be_763b1b436e4a -->|method| b20d8c19_2559_75e5_38da_179f2daff259 d847678f_6a2c_82a6_7e3e_2e8790313ca9["mapFromDriverValue()"] af6d71cb_a439_6e4e_54be_763b1b436e4a -->|method| d847678f_6a2c_82a6_7e3e_2e8790313ca9 aa7e25ab_74d3_4171_5aee_d962d5c777e0["getSQLType()"] af6d71cb_a439_6e4e_54be_763b1b436e4a -->|method| aa7e25ab_74d3_4171_5aee_d962d5c777e0
Relationship Graph
Source Code
drizzle-orm/src/pg-core/columns/numeric.ts lines 40–67
export class PgNumeric<T extends ColumnBaseConfig<'string', 'PgNumeric'>> extends PgColumn<T> {
static override readonly [entityKind]: string = 'PgNumeric';
readonly precision: number | undefined;
readonly scale: number | undefined;
constructor(table: AnyPgTable<{ name: T['tableName'] }>, config: PgNumericBuilder<T>['config']) {
super(table, config);
this.precision = config.precision;
this.scale = config.scale;
}
override mapFromDriverValue(value: unknown): string {
if (typeof value === 'string') return value;
return String(value);
}
getSQLType(): string {
if (this.precision !== undefined && this.scale !== undefined) {
return `numeric(${this.precision}, ${this.scale})`;
} else if (this.precision === undefined) {
return 'numeric';
} else {
return `numeric(${this.precision})`;
}
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the PgNumeric class?
PgNumeric is a class in the drizzle-orm codebase, defined in drizzle-orm/src/pg-core/columns/numeric.ts.
Where is PgNumeric defined?
PgNumeric is defined in drizzle-orm/src/pg-core/columns/numeric.ts at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free