Type alias AnyColumnWithTable<DB, TB>

AnyColumnWithTable<DB, TB>: DrainOuterGeneric<{
    [T in TB]: T extends string
        ? keyof DB[T] extends string
            ? `${T}.${keyof DB[T]}`
            : never
        : never

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


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 = AnyColumnWithTable<Database, 'person' | 'pet'>

// Columns == 'person.id' | 'pet.name' | 'pet.species'

Type Parameters

  • DB

  • TB extends keyof DB

Generated using TypeDoc