Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

AnyColumnWithTable

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

Example:

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 AnyColumnWithTable<DB, TB extends keyof DB> = [T in TB]: `${T & string}.${keyof DB[T] & string}`[TB];

§Type Parameters

§
TB extends keyof DB
[src]

§Type

§
[T in TB]: `${T & string}.${keyof DB[T] & string}`[TB]
[src]