# Class: CompositeType

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

# Hierarchy



# Properties

# Readonly arrayOid

arrayOid: number

Inherited from Type.arrayOid

Defined in src/pg-structure/base/type.ts:39

If typarray is not 0 then it identifies another row in pg_type, which is the array type having this type as element.

# category

category: TypeCategory

Inherited from Type.category

Defined in src/pg-structure/base/type.ts:84

An arbitrary classification of PostgreSQL data types that is used by the PostgreSQL parser to determine which implicit casts should be “preferred”. See related doc here

# Readonly classOid

classOid: number

Inherited from Type.classOid

Defined in src/pg-structure/base/type.ts:42

Object identifier of PostgreSQL class (pg_catalog.pg_class) for the Entity

# Readonly columns

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

Defined in src/pg-structure/type/composite-type.ts:48

All columns of the composite type as an {@link IndexableArray indexable array} ordered by same order they are defined in database composite type.

# Example

const isAvailable  = composite.columns.has('id');
const columnNames  = composite.columns.map(column => column.name);
const column       = composite.columns.get('user_id');
const name         = column.name;

composite.columns.forEach(column => console.log(column.name));

name Entity#columns

# Optional Readonly comment

comment? : undefined | string

Inherited from MaterializedView.comment

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

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

# hasLength

hasLength: boolean

Inherited from Type.hasLength

Defined in src/pg-structure/base/type.ts:87

Whether the type has length property.

# hasPrecision

hasPrecision: boolean

Inherited from Type.hasPrecision

Defined in src/pg-structure/base/type.ts:93

Whether the type has precision property.

# hasScale

hasScale: boolean

Inherited from Type.hasScale

Defined in src/pg-structure/base/type.ts:90

Whether the type has scale property.

# Optional Readonly internalName

internalName? : undefined | string

Inherited from Type.internalName

Defined in src/pg-structure/base/type.ts:66

Internal name of type. Available for some builtin types.

# Example

const name = doublePrecisionType.name; // double precision
const shortName = doublePrecisionType.internalName; // float8

# Readonly name

name: string

Inherited from MaterializedView.name

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

Name of the database object.

# Readonly oid

oid: number

Inherited from Type.oid

Defined in src/pg-structure/base/type.ts:36

Object identifier for the Entity

# Optional relationKind

relationKind? : RelationKindLetter

Defined in src/pg-structure/type/composite-type.ts:26

All entities such as tables, views and materialized view are also composite types in PostgreSQL. This is the entity type of composite type if any.

# schema

schema: Schema

Inherited from Type.schema

Overrides Constraint.schema

Defined in src/pg-structure/base/type.ts:47

Schema this type belongs to.

# Optional Readonly shortName

shortName? : undefined | string

Inherited from Type.shortName

Defined in src/pg-structure/base/type.ts:77

Short name of type. Available for some builtin types.

# Example

const name = timetzType.name; // time with time zone
const shortName = timetzType.shortName; // time with time zone
const name2 = varcharType.name; // character varying
const shortName2 = varcharType.name; // varchar

# Accessors

# commentData

get commentData(): JSONData | undefined

Inherited from MaterializedView.commentData

Defined in src/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 MaterializedView.commentWithoutData

Defined in src/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 MaterializedView.db

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

Database of the database object.

Returns: Db

# entity

get entity(): Entity | undefined

Defined in src/pg-structure/type/composite-type.ts:31

All entities such as tables, views and materialized view are also composite types in PostgreSQL. This is the entity composite type is based on, if any.

Returns: Entity | undefined

# fullCatalogName

get fullCatalogName(): string

Inherited from MaterializedView.fullCatalogName

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

Full name of the database object including database name.

Returns: string

# fullName

get fullName(): string

Inherited from Type.fullName

Overrides Constraint.fullName

Defined in src/pg-structure/base/type.ts:55

Full name of the object with '.' notation including Schema name.

# Example

const fullName = type.fullName; // public.phone_number

Returns: string

# nameCaseType

get nameCaseType(): CaseType

Inherited from MaterializedView.nameCaseType

Defined in src/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 MaterializedView.separator

Defined in src/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