# Class: Schema

Class which represent a PostgreSQL schema. Provides attributes and methods for details of the schema.

# Hierarchy

# Properties

# Optional comment

comment? : undefined | string

Inherited from DbObject.comment

Defined in pg-structure/base/db-object.ts:75

Comment of the database object defined in database including {@link DbObject#commentData comment data}.


# materializedViews

materializedViews: IndexableArray‹MaterializedView, "name", never, true› = IndexableArray.throwingFrom([], "name")

Defined in pg-structure/schema.ts:87

All materialized views of the schema as an {@link IndexableArray indexable array} ordered by name.

# Example

const mViewArray   = schema.materializedViews;
const isAvailable  = schema.materializedViews.has('admin_person');
const mView        = schema.materializedViews.get('big_account');
const name         = mView.name;

schema.materializedViews.forEach(mView => console.log(mView.name));

# name

name: string

Inherited from DbObject.name

Defined in pg-structure/base/db-object.ts:42

Name of the database object.


# oid

oid: number

Defined in pg-structure/schema.ts:39

Object identifier for the Schema


# schema

schema: Schema = this

Overrides DbObject.schema

Defined in pg-structure/schema.ts:103

Schema of the object.


# tables

tables: IndexableArray‹Table, "name", never, true› = IndexableArray.throwingFrom([], "name")

Defined in pg-structure/schema.ts:61

All tables of the schema as an {@link IndexableArray indexable array} ordered by name.

# Example

const tableArray   = schema.tables;
const isAvailable  = schema.tables.has('person');
const table        = schema.tables.get('account');
const name         = table.name;

schema.tables.forEach(table => console.log(table.name));

# types

types: IndexableArray‹Type, "name", "shortName", true› = IndexableArray.throwingFrom([], "name", "shortName")

Defined in pg-structure/schema.ts:98

All custom database types of the schema as an {@link IndexableArray indexable array} ordered by name.

# Example

const typeArray    = schema.types;
const isAvailable  = schema.types.has('address');
const type         = schema.types.get('address');
const columns      = type.columns;

# views

views: IndexableArray‹View, "name", never, true› = IndexableArray.throwingFrom([], "name")

Defined in pg-structure/schema.ts:74

All views of the schema as an {@link IndexableArray indexable array} ordered by name.

# Example

const viewArray    = schema.views;
const isAvailable  = schema.views.has('admin_person');
const view         = schema.views.get('big_account');
const name         = view.name;

schema.views.forEach(view => console.log(view.name));

# Accessors

# commentData

get commentData(): JSONData | undefined

Inherited from DbObject.commentData

Defined in pg-structure/base/db-object.ts:102

Data which is extracted from database object's comment. Data is extracted from text between special case-insesitive tag (default: [pg-structure][/pg-structure]) and converted to JavaScript object using JSON5. Token name can be specified by using commentDataToken arguments. For details of JSON5, see it's web site: https://json5.org.

# Example

// "Account details. [pg-structure]{ extraData: 2 }[/pg-structure] Also used for logging."
table.comment;               // "Account details. [pg-structure]{ extraData: 2 }[/pg-structure] Also used for logging."
table.commentWithoutData;    // "Account details.  Also used for logging."
table.commentData;           // { extraData: 2 }
table.commentData.extraData; // 2

Returns: JSONData | undefined


# commentWithoutData

get commentWithoutData(): string | undefined

Inherited from DbObject.commentWithoutData

Defined in pg-structure/base/db-object.ts:85

Description or comment of the database object defined in database. If comment contains {@link DbObject#commentData comment data}, it is removed.

# Example

// "Account details. [pg-structure]{ extraData: 2 }[/pg-structure] Also used for logging."
table.commentWithoutData;    // "Account details.  Also used for logging."

Returns: string | undefined


# db

get db(): Db

Inherited from DbObject.db

Defined in pg-structure/base/db-object.ts:68

Database of the database object.

Returns: Db


# entities

get entities(): IndexableArray‹Entity, "name", never, true›

Defined in pg-structure/schema.ts:46

All entities (tables and views) of the schema as an {@link IndexableArray indexable array} ordered by name.

Returns: IndexableArray‹Entity, "name", never, true›


# fullCatalogName

get fullCatalogName(): string

Inherited from DbObject.fullCatalogName

Defined in pg-structure/base/db-object.ts:35

Full name of the database object including database name.

Returns: string


# fullName

get fullName(): string

Overrides DbObject.fullName

Defined in pg-structure/schema.ts:105

Returns: string


# nameCaseType

get nameCaseType(): CaseType

Inherited from DbObject.nameCaseType

Defined in pg-structure/base/db-object.ts:54

Letter casing (i.e snakeCase or camelCase) of the database object name.

# Example

const name = entity.name;                        // ProductDetail
const caseType = entity.nameCaseType;            // camelCase

const otherEntity = otherEntity.name;            // member_protocol
const otherCaseType = otherEntity.nameCaseType;  // snakeCase

Returns: CaseType


# separator

get separator(): string

Inherited from DbObject.separator

Defined in pg-structure/base/db-object.ts:61

Separator used in database object name. Empty string for came case and underscore for (_) snake case.

Returns: string

# Methods

# get

get(path: string): Entity | Column

Defined in pg-structure/schema.ts:118

Returns table, view or column on given path in schema. Path should be in dot (.) notation.

# Example

const table  = db.get('contact');      // Returns contact table in public schema.
const column = db.get('contact.name'); // Returns name column of the contact table.

Parameters:

Name Type Description
path string is the path of the requested item in dot (.) notation such as 'public.contact'

Returns: Entity | Column

requested database object.