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
bigInteger vs integer:
integer is sufficient for IDs or counts, but use bigInteger for
timestamps (milliseconds) or very large numbers.String Types
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
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.Practical Example
Type conversion example for an actual User Entity.Next Steps
Generated Types
Types of generated types and their uses
Zod Validation
Runtime validation with Zod
E2E Type Safety
End-to-end type safety
Field Types
Complete Entity field type reference