pg-structure / Index
# Class: Index
Class which represent a database index. Provides attributes and methods for details of the index.
# Hierarchy
-
↳ Index
# Properties
# columnsAndExpressions
• Readonly
columnsAndExpressions: (string | Column)[]
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.
Defined in: pg-structure/index.ts:111
# comment
• Optional
Readonly
comment: undefined | string
Comment of the database object defined in database including {@link DbObject#commentData comment data}.
Inherited from: DbObject.comment
Defined in: pg-structure/base/db-object.ts:75
# isExclusion
• Readonly
isExclusion: boolean
If true, this index supports an exclusion constraint.
Defined in: pg-structure/index.ts:56
# isPrimaryKey
• Readonly
isPrimaryKey: boolean
If true, this index represents the primary key of the table ({@link Index#isUnique isUnique} is always true for primary keys.)
Defined in: pg-structure/index.ts:51
# isUnique
• Readonly
isUnique: boolean
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 unique constraint.
Defined in: pg-structure/index.ts:46
# name
• Readonly
name: string
Name of the database object.
Defined in: pg-structure/base/db-object.ts:42
# oid
• Readonly
oid: number
Object identifier for the Schema
Defined in: pg-structure/index.ts:36
# parent
• Readonly
parent: Table | MaterializedView
Parent database object this column belongs to.
Defined in: pg-structure/index.ts:85
# partialIndexExpression
• Readonly
partialIndexExpression: undefined | string
If index is a partial index, partial index expression
Defined in: pg-structure/index.ts:66
# Accessors
# columns
• get columns(): default<Column, name, never, true>
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: default<Column, name, never, true>
Defined in: pg-structure/index.ts:101
# commentData
• get commentData(): undefined | null | string | number | boolean | JSONObject | JSONArray
Data which is extracted from database object's comment. Data is extracted from text between special case-insensitive tag
(default: [pg-structure][/pg-structure]
) and converted to JavaScript object using JSON5 (opens new window).
Token name can be specified by using commentDataToken
arguments.
For details of JSON5 (opens new window), see it's web site: https://json5.org (opens new window).
# 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: undefined | null | string | number | boolean | JSONObject | JSONArray
Defined in: pg-structure/base/db-object.ts:102
# commentWithoutData
• get commentWithoutData(): undefined | string
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: undefined | string
Defined in: pg-structure/base/db-object.ts:85
# db
• get db(): Db
Database of the database object.
Returns: Db
Defined in: pg-structure/base/db-object.ts:68
# fullCatalogName
• get fullCatalogName(): string
Full name of the database object including database name.
Returns: string
Defined in: pg-structure/base/db-object.ts:35
# fullName
• get fullName(): string
Full name of the database object including parent name.
Returns: string
Defined in: pg-structure/index.ts:38
# isPartial
• get isPartial(): boolean
If true, this index is a partial index.
Returns: boolean
Defined in: pg-structure/index.ts:61
# materializedView
• get materializedView(): undefined | MaterializedView
MaterializedView which this index belongs to.
Returns: undefined | MaterializedView
Defined in: pg-structure/index.ts:78
# nameCaseType
• get nameCaseType(): CaseType
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
Defined in: pg-structure/base/db-object.ts:54
# schema
• get schema(): Schema
Returns: Schema
Defined in: pg-structure/index.ts:90
# separator
• get separator(): string
Separator used in database object name. Empty string for came case and underscore for (_) snake case.
Returns: string
Defined in: pg-structure/base/db-object.ts:61
# table
• get table(): undefined | Table
Table which this index belongs to.
Returns: undefined | Table
Defined in: pg-structure/index.ts:71