Type alias AnyColumn<DB, TB>

AnyColumn<DB, TB>: {
    [T in TB]: keyof DB[T]
}[TB] & string

Given a database type and a union of table names in that db, returns a union type with all possible column names.


interface Person {
id: number

interface Pet {
name: string
species: 'cat' | 'dog'

interface Movie {
stars: number

interface Database {
person: Person
pet: Pet
movie: Movie

type Columns = AnyColumn<Database, 'person' | 'pet'>

// Columns == 'id' | 'name' | 'species'

Type Parameters

  • DB

  • TB extends keyof DB

Generated using TypeDoc