Skip to main content

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

R
interface
required
A table interface with column definitions.

Behavior

  • Extracts the first type parameter (SelectType) from each ColumnType<SelectType, InsertType, UpdateType>
  • For regular types without ColumnType, uses the type as-is
  • Excludes columns where SelectType is never
  • 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 with never as the select type are excluded:

Common Patterns

Combining with Other Utility Types

Repository Pattern

Source

View source on GitHub