# Class: Index

Class which represent a database index. Provides attributes and methods for details of the index.

# Hierarchy

# Properties

# Readonly columnsAndExpressions

columnsAndExpressions: Array‹Column | string› = []

Defined in src/pg-structure/index.ts:111

List of columns and {@link Expression expressions} of index, in order their ordinal position within the index. If index does not have any columns or {@link Expression expressions} this is empty array. To get only columns use columns method.

# 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}.

# Readonly isExclusion

isExclusion: boolean

Defined in src/pg-structure/index.ts:56

If true, this index supports an exclusion constraint.

# Readonly isPrimaryKey

isPrimaryKey: boolean

Defined in src/pg-structure/index.ts:51

If true, this index represents the primary key of the table ({@link Index#isUnique isUnique} is always true for primary keys.)

# Readonly isUnique

isUnique: boolean

Defined in src/pg-structure/index.ts:46

If true, this is a unique index. Please note that all unique constraints have a unique index created by PostgreSQL automatically, but unique indexes may not have unqiue constraint.

# 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

Defined in src/pg-structure/index.ts:36

Object identifier for the Schema

# Readonly parent

parent: Table | MaterializedView

Defined in src/pg-structure/index.ts:85

Parent database object this column belongs to.

# Readonly partialIndexExpression

partialIndexExpression: string | undefined

Defined in src/pg-structure/index.ts:66

If index is a partial index, partial index expression

# Accessors

# columns

get columns(): IndexableArray‹Column, "name", never, true›

Defined in src/pg-structure/index.ts:101

List of columns of index, in order their ordinal position within the index. If index does not have any columns this is empty array. Please note that, non reference expressions such as CONCAT(name, surname) is not included. To access expressions and columns together use columnsAndExpressions method.

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

# 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

# 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

Overrides Constraint.fullName

Defined in src/pg-structure/index.ts:38

Returns: string

# isPartial

get isPartial(): boolean

Defined in src/pg-structure/index.ts:61

If true, this index is a partial index.

Returns: boolean

# materializedView

get materializedView(): MaterializedView | undefined

Defined in src/pg-structure/index.ts:78

MaterializedView which this index belongs to.

Returns: MaterializedView | undefined

# 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

# schema

get schema(): Schema

Overrides Constraint.schema

Defined in src/pg-structure/index.ts:90

Schema this index belongs to.

Returns: Schema

# 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

# table

get table(): Table | undefined

Defined in src/pg-structure/index.ts:71

Table which this index belongs to.

Returns: Table | undefined