Skip to content

Types

The result of calling extractSchemas is a Record<string, Schema> — a map of schema name to schema description. Click the buttons to expand any type inline.

Schema

/** extractSchemas generates a record of all the schemas extracted, indexed by schema name. The schemas are instances of this type. */
export type Schema {
name: string
domains: DomainDetails[]
enums: EnumDetails[]
ranges: RangeDetails[]
tables: TableDetails[]
foreignTables: ForeignTableDetails[]
views: ViewDetails[]
materializedViews: MaterializedViewDetails[]
compositeTypes: CompositeTypeDetails[]
functions: FunctionDetails[]
procedures: ProcedureDetails[]

extractSchemas options

/** This is the options object that can be passed to `extractSchemas`. */
export interface ExtractSchemaOptions {
// Will contain an array of schema names to extract. If undefined, all non-system schemas will be extracted.
schemas?: string[]
// Filter function that you can use if you want to exclude certain items from the schemas.
typeFilter?: (pgType: PgType) => boolean
// extractShemas will always attempt to parse view definitions to discover the "source" of each column, i.e. the table or view that it is derived from. If this option is set to `true`, it will attempt to follow this source and copy values like indices, isNullable, etc. so that the view data is closer to what the database reflects.
resolveViews?: boolean
// Called with the number of types to extract.
onProgressStart?: (total: number) => void
// Called once for each type that is extracted.
onProgress?: () => void
// Called when all types have been extracted.
onProgressEnd?: () => void

PgType (base)

Every detail type extends PgType. It provides the four fields common to all database objects.

/** Base type for Postgres objects. */
export type PgType {
// The name of the object.
name: string
// The name of the schema that the object is in.
schemaName: string
// The kind of the object.
kind: K
// The comment on the object, if any.
comment: string | null