pg-structure / Trigger

# Class: Trigger

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

# Hierarchy

# Properties

# 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


# condition

Readonly condition: null | string

WHEN condition of the trigger, null if none.

Defined in: pg-structure/trigger.ts:100


# events

Readonly events: TriggerEvent[]

Events that fires the trigger.

Defined in: pg-structure/trigger.ts:97


# function

Readonly function: NormalFunction

[[Function]] of trigger.

Defined in: pg-structure/trigger.ts:88


# isDeferrable

Readonly isDeferrable: boolean

Whether constraint trigger is deferrable

Defined in: pg-structure/trigger.ts:106


# isEnabled

Readonly isEnabled: TriggerEnabled

In which session_replication_role modes the trigger fires

Defined in: pg-structure/trigger.ts:103


# isInitiallyDeferred

Readonly isInitiallyDeferred: boolean

Whether constraint trigger is initially deferred

Defined in: pg-structure/trigger.ts:109


# name

Readonly name: string

Name of the database object.

Inherited from: DbObject.name

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


# oid

Readonly oid: number

Object identifier for the Trigger

Defined in: pg-structure/trigger.ts:43


# orientation

Readonly orientation: TriggerOrientation

whether the trigger fires once for each processed row or once for each statement.

Defined in: pg-structure/trigger.ts:91


# parent

Readonly parent: Table | View

Parent database object this trigger is defined in.

Defined in: pg-structure/trigger.ts:48


# timing

Readonly timing: TriggerTiming

Time at which the trigger fires.

Defined in: pg-structure/trigger.ts:94

# Accessors

# 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 object with '.' notation including Schema name.

# Example

const fullName = trigger.fullName; // public.member.updated_at

Returns: string

Defined in: pg-structure/trigger.ts:83


# 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

Schema of the object.

Returns: Schema

Defined in: pg-structure/trigger.ts:73


# 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 this trigger defined in if it belongs to a table.

# Example

const table = trigger.table; // Table instance

Returns: undefined | Table

Defined in: pg-structure/trigger.ts:56


# view

• get view(): undefined | View

View this trigger defined in if it belongs to a view.

# Example

const view = trigger.view; // View instance

Returns: undefined | View

Defined in: pg-structure/trigger.ts:67