PostgresQueryInterface

Extends:

QueryInterface → PostgresQueryInterface

The interface that Sequelize uses to talk with Postgres database

Method Summary

Public Methods
public

async dropAllEnums(options: object): Promise

Drop all enums from database (Postgres only)

public

async dropEnum(enumName: string, options: object): Promise

Drop specified enum from database (Postgres only)

public

async dropTable(tableName: *, options: *)

Since postgres has a special case for enums, we should drop the related enum type within the table and attribute

public

async getForeignKeyReferencesForTable(tableName: *, options: *): *

public

async pgListEnums(tableName: string, options: object): Promise

List all enums (Postgres only)

Inherited Summary

From class QueryInterface
public

async addColumn(table: string, key: string, attribute: object, options: object): Promise

Add a new column to a table

public

async addConstraint(tableName: string, options: object): Promise

Add a constraint to a table

public

async addIndex(tableName: string | object, attributes: Array, options: object, rawTablename: string): Promise

Add an index to a column

public

async bulkDelete(tableName: string, where: object, options: object, model: Model): Promise

Delete multiple records from a table

public

async bulkInsert(tableName: string, records: Array, options: object, attributes: object): Promise

Insert multiple records into a table

public

async bulkUpdate(tableName: string, values: object, identifier: object, options: object, attributes: object): Promise

Update multiple records of a table

public

async changeColumn(tableName: string, attributeName: string, dataTypeOrOptions: object, options: object): *

Change a column definition

public

async createDatabase(database: string, options: object): Promise

Create a database

public

async createFunction(functionName: string, params: Array, returnType: string, language: string, body: string, optionsArray: Array, options: object): Promise

Create an SQL function

public

async createSchema(schema: string, options: object): Promise

Create a schema

public

async createTable(tableName: string, attributes: object, options: object, model: Model): Promise

Create a table with given set of attributes

public

async describeTable(tableName: string, options: object): Promise<object>

Describe a table structure

public

async dropAllSchemas(options: object): Promise

Drop all schemas

public

async dropAllTables(options: object): Promise

Drop all tables from database

public

async dropDatabase(database: string, options: object): Promise

Drop a database

public

async dropFunction(functionName: string, params: Array, options: object): Promise

Drop an SQL function

public

async dropSchema(schema: string, options: object): Promise

Drop a schema

public

async dropTable(tableName: string, options: object): Promise

Drop a table from database

public

async getForeignKeyReferencesForTable(tableName: string, options: object): *

Get foreign key references details for the table

public

async getForeignKeysForTables(tableNames: string[], options: object): Promise

Returns all foreign key constraints of requested tables

public

async removeColumn(tableName: string, attributeName: string, options: object): *

Remove a column from a table

public

async removeConstraint(tableName: string, constraintName: string, options: object): *

Remove a constraint from a table

public

async removeIndex(tableName: string, indexNameOrAttributes: string | string[], options: object): Promise

Remove an already existing index from a table

public

async renameColumn(tableName: string, attrNameBefore: string, attrNameAfter: string, options: object): Promise

Rename a column

public

async renameFunction(oldFunctionName: string, params: Array, newFunctionName: string, options: object): Promise

Rename an SQL function

public

async renameTable(before: string, after: string, options: object): Promise

Rename a table

public

async showAllSchemas(options: object): Promise<Array>

Show all schemas

public

async upsert(tableName: string, insertValues: object, updateValues: object, where: object, options: object): Promise<boolean, ?number>

Upsert

Public Methods

public async dropAllEnums(options: object): Promise source

Drop all enums from database (Postgres only)

Params:

Name Type Attribute Description
options object

Query options

Return:

Promise

public async dropEnum(enumName: string, options: object): Promise source

Drop specified enum from database (Postgres only)

Params:

Name Type Attribute Description
enumName string
  • optional

Enum name to drop

options object

Query options

Return:

Promise

public async dropTable(tableName: *, options: *) source

Since postgres has a special case for enums, we should drop the related enum type within the table and attribute

Params:

Name Type Attribute Description
tableName *
options *

public async getForeignKeyReferencesForTable(tableName: *, options: *): * source

Get foreign key references details for the table

Those details contains constraintSchema, constraintName, constraintCatalog tableCatalog, tableSchema, tableName, columnName, referencedTableCatalog, referencedTableCatalog, referencedTableSchema, referencedTableName, referencedColumnName. Remind: constraint informations won't return if it's sqlite.

Params:

Name Type Attribute Description
tableName *
options *

Return:

*

public async pgListEnums(tableName: string, options: object): Promise source

List all enums (Postgres only)

Params:

Name Type Attribute Description
tableName string
  • optional

Table whose enum to list

options object
  • optional

Query options

Return:

Promise

Copyright © 2014–present Sequelize contributors
Licensed under the MIT License.
https://sequelize.org/master/class/lib/dialects/postgres/query-interface.js~PostgresQueryInterface.html