Type Conversion Overview
Field Types
Entity Prop → TypeScript Type auto-conversion and type safety
Nullable Support
nullable: true → T | null optional null handling
Array Types
type[] → T[] array type auto-generation
Relation Types
BelongsToOne → number (FK) relation field type conversion
Basic Type Conversion
Shows how each Entity field type is converted to TypeScript types.Numeric Types
| Entity Type | TypeScript Type | Description |
|---|---|---|
integer | number | 32bit integer |
integer[] | number[] | Integer array |
bigInteger | bigint | 64bit integer (large numbers) |
bigInteger[] | bigint[] | Large integer array |
bigInteger vs integer:
integer is sufficient for IDs or counts, but use bigInteger for timestamps (milliseconds) or very large numbers.String Types
| Entity Type | TypeScript Type | Description |
|---|---|---|
string | string | String |
string[] | string[] | String array |
Boolean Types
Date Types
UUID Types
TypeScript doesn’t have a dedicated UUID type, so it’s represented as
string. Format is validated with .uuid() in Zod validation.Numeric Precision Types
Two types for handling PostgreSQL high-precision numbers.number vs numeric
| Entity Type | TypeScript Type | PostgreSQL Type | Use Case |
|---|---|---|---|
number | number | real, double precision, numeric | General calculations (floating point) |
numeric | string | numeric | Financial calculations (fixed point) |
Enum Types
Entity Enums are converted to TypeScript Union types.- Autocomplete support
- Type safety guaranteed
- Compile errors for invalid values
JSON Type
Used when storing complex object structures as JSON.The
json type references the Zod schema specified by id. This schema must be defined directly in {entity}.types.ts.Virtual Type
Computed fields not stored in the database.Vector Type
Type for vector search (pgvector).dimensions doesn’t affect TypeScript types, but is used in PostgreSQL schema and Zod validation.Relation Types
Fields representing relationships between Entities.BelongsToOne (Many-to-One)
OneToOne (One-to-One)
HasMany / ManyToMany
HasMany and ManyToMany are not included in base types. When you define a Subset, those types are included in the Subset type.Nullable Handling
nullable: true is converted to TypeScript Union type.
Complete Type Mapping Table
Mapping table of all Entity Prop types to TypeScript types.| Entity Type | TypeScript Type | Notes |
|---|---|---|
integer | number | 32bit integer |
integer[] | number[] | Integer array |
bigInteger | bigint | 64bit integer |
bigInteger[] | bigint[] | Large integer array |
string | string | String |
string[] | string[] | String array |
number | number | Floating point |
number[] | number[] | Floating point array |
numeric | string | Fixed point (precision as string) |
numeric[] | string[] | Fixed point array |
boolean | boolean | Boolean |
boolean[] | boolean[] | Boolean array |
date | Date | Date (string in JSON) |
date[] | Date[] | Date array |
uuid | string | UUID string |
uuid[] | string[] | UUID array |
enum | EnumType | Union type |
enum[] | EnumType[] | Union type array |
json | CustomType | Custom object type |
virtual | CustomType | Computed field |
vector | number[] | Vector (pgvector) |
vector[] | number[][] | Vector array |
tsvector | string | Full-text search (PostgreSQL) |
BelongsToOne | number | Foreign Key (FK) |
OneToOne (hasJoinColumn) | number | Foreign Key (FK) |
HasMany | - | Not in Base type |
ManyToMany | - | Not in Base type |