Type Signature
Overview
Selectable<T> is a utility type that extracts the select type from all columns in a table interface. It resolves the SelectType from any ColumnType definitions and creates a type representing what you get when selecting from the table.
Type Parameters
A table interface with column definitions.
Behavior
- Extracts the first type parameter (
SelectType) from eachColumnType<SelectType, InsertType, UpdateType> - For regular types without
ColumnType, uses the type as-is - Excludes columns where
SelectTypeisnever - All fields in the resulting type are required (not optional)
Examples
Basic Usage
Using with Query Results
With Complex Column Types
Partial Selects
When selecting specific columns, TypeScript infers the exact type:Excluding Never Columns
Columns withnever as the select type are excluded:
Common Patterns
Combining with Other Utility Types
Repository Pattern
Related Types
ColumnType<SelectType, InsertType, UpdateType>- Define different types for different operationsInsertable<T>- Extract insert types from a table interfaceUpdateable<T>- Extract update types from a table interfaceGenerated<T>- Shortcut for database-generated columns