# Class: Trigger

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

# Hierarchy

# Properties

# 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 condition

condition: string | null

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

WHEN condition of the trigger, null if none.


# Readonly events

events: TriggerEvent[]

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

Events that fires the trigger.


# Readonly function

function: NormalFunction

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

[[Function]] of trigger.


# Readonly isDeferrable

isDeferrable: boolean

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

Whether constraint trigger is deferrable


# Readonly isEnabled

isEnabled: TriggerEnabled

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

In which session_replication_role modes the trigger fires


# Readonly isInitiallyDeferred

isInitiallyDeferred: boolean

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

Whether constraint trigger is initially deferred


# 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/trigger.ts:43

Object identifier for the Trigger


# Readonly orientation

orientation: TriggerOrientation

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

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


# Readonly parent

parent: Table | View

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

Parent database object this trigger is defined in.


# Readonly timing

timing: TriggerTiming

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

Time at which the trigger fires.

# 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


# 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/trigger.ts:83

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

# Example

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

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


# schema

get schema(): Schema

Overrides Constraint.schema

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

Schema of the object.

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/trigger.ts:56

Table this trigger defined in if it belongs to a table.

# Example

const table = trigger.table; // Table instance

Returns: Table | undefined


# view

get view(): View | undefined

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

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

# Example

const view = trigger.view; // View instance

Returns: View | undefined