Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QueryInterface

The interface that Sequelize uses to talk to all databases.

This interface is available through sequelize.queryInterface. It should not be commonly used, but it's referenced anyway, so it can be used.

Hierarchy

  • QueryInterface

Index

Constructors

Properties

queryGenerator: AbstractQueryGenerator

Returns the dialect-specific sql generator.

We don't have a definition for the QueryGenerator, because I doubt it is commonly in use separately.

sequelize: Sequelize

Returns the current sequelize instance.

Methods

  • addIndex(tableName: TableName, attributes: string[], options?: QueryInterfaceIndexOptions, rawTablename?: string): Promise<void>
  • addIndex(tableName: TableName, options: { benchmark?: boolean; bind?: BindOrReplacements; concurrently?: boolean; fieldMap?: FieldMap; fields: (string | Literal | Fn | IndexField)[]; instance?: Model<any, any>; logging?: boolean | ((sql: string, timing?: number) => void); mapToModel?: boolean; name?: string; nest?: boolean; operator?: string; parser?: null | string; plain?: boolean; prefix?: string; raw?: boolean; replacements?: {}; retry?: RetryOptions; transaction?: null | Transaction; type?: IndexType; unique?: boolean; useMaster?: boolean; using?: string; where?: WhereOptions<any> }, rawTablename?: string): Promise<void>
  • Adds a new index to a table

    Parameters

    Returns Promise<void>

  • Parameters

    • tableName: TableName
    • options: { benchmark?: boolean; bind?: BindOrReplacements; concurrently?: boolean; fieldMap?: FieldMap; fields: (string | Literal | Fn | IndexField)[]; instance?: Model<any, any>; logging?: boolean | ((sql: string, timing?: number) => void); mapToModel?: boolean; name?: string; nest?: boolean; operator?: string; parser?: null | string; plain?: boolean; prefix?: string; raw?: boolean; replacements?: {}; retry?: RetryOptions; transaction?: null | Transaction; type?: IndexType; unique?: boolean; useMaster?: boolean; using?: string; where?: WhereOptions<any> }
      • Optional benchmark?: boolean

        Pass query execution time in milliseconds as second argument to logging function (options.logging).

      • Optional bind?: BindOrReplacements

        Either an object of named parameter bindings in the format $param or an array of unnamed values to bind to $1, $2, etc in your SQL.

      • Optional concurrently?: boolean

        PostgreSQL will build the index without taking any write locks. Postgres only.

        default

        false

      • Optional fieldMap?: FieldMap

        Map returned fields to arbitrary names for SELECT query type if options.fieldMaps is present.

      • fields: (string | Literal | Fn | IndexField)[]

        The fields to index.

      • Optional instance?: Model<any, any>

        A sequelize instance used to build the return instance

      • Optional logging?: boolean | ((sql: string, timing?: number) => void)

        A function that gets executed while running the query to log the sql.

      • Optional mapToModel?: boolean

        Map returned fields to model's fields if options.model or options.instance is present. Mapping will occur before building the model instance.

      • Optional name?: string

        The name of the index. Defaults to model name + _ + fields concatenated

      • Optional nest?: boolean

        If true, transforms objects with . separated property names into nested objects using dottie.js. For example { 'user.username': 'john' } becomes { user: { username: 'john' }}. When nest is true, the query type is assumed to be 'SELECT', unless otherwise specified

        default

        false

      • Optional operator?: string

        Index operator type. Postgres only

      • Optional parser?: null | string

        For FULLTEXT columns set your parser

      • Optional plain?: boolean

        Sets the query type to SELECT and return a single row

      • Optional prefix?: string

        Prefix to append to the index name.

      • Optional raw?: boolean

        If true, sequelize will not try to format the results of the query, or build an instance of a model from the result

      • Optional replacements?: {}

        Only named replacements are allowed in query interface methods.

        • [key: string]: unknown
      • Optional retry?: RetryOptions
      • Optional transaction?: null | Transaction

        The transaction in which this query must be run.

        If CLS is enabled and a transaction is running in the current CLS context, that transaction will be used, unless null or a Transaction is manually specified here.

      • Optional type?: IndexType

        Index type. Only used by mysql. One of UNIQUE, FULLTEXT and SPATIAL

      • Optional unique?: boolean

        Should the index by unique? Can also be triggered by setting type to UNIQUE

        default

        false

      • Optional useMaster?: boolean

        Force the query to use the write pool, regardless of the query type.

        default

        false

      • Optional using?: string

        The method to create the index by (USING statement in SQL). BTREE and HASH are supported by mysql and postgres. Postgres additionally supports GIST, SPGIST, BRIN and GIN.

      • Optional where?: WhereOptions<any>

        Optional where parameter for index. Can be used to limit the index to certain rows.

    • Optional rawTablename: string

    Returns Promise<void>

  • Commit an already started transaction

    Parameters

    Returns Promise<void>

  • Creates a database

    Parameters

    Returns Promise<void>

  • createFunction(functionName: string, params: FunctionParam[], returnType: string, language: string, body: string, optionsArray?: string[], options?: CreateFunctionOptions): Promise<void>
  • Postgres only. Create a function

    Parameters

    Returns Promise<void>

  • Queries the schema (table list).

    Parameters

    • Optional schema: string

      The schema to query. Applies only to Postgres.

    • Optional options: QueryRawOptions

    Returns Promise<void>

  • Creates a table with specified attributes.

    Type parameters

    Parameters

    Returns Promise<void>

  • Postgres only. Creates a trigger on specified table to call the specified function with supplied parameters.

    Parameters

    Returns Promise<void>

  • Return database version

    Parameters

    Returns Promise<string>

  • Decrements a row value

    Type parameters

    Parameters

    Returns Promise<object>

  • Defer constraints

    Parameters

    Returns Promise<void>

  • Deletes a row

    Parameters

    Returns Promise<object>

  • Describe a table

    Parameters

    • tableName: TableName
    • Optional options: string | ({ schema?: string; schemaDelimiter?: string } & Logging)

    Returns Promise<ColumnsDescription>

  • Drops all defined enums

    Parameters

    Returns Promise<void>

  • Creates a database

    Parameters

    Returns Promise<void>

  • Postgres only. Drops a function

    Parameters

    Returns Promise<void>

  • Drops the specified schema (table).

    Parameters

    • Optional schema: string

      The schema to query. Applies only to Postgres.

    • Optional options: QueryRawOptions

    Returns Promise<void>

  • Drops the specified table.

    Parameters

    Returns Promise<void>

  • Postgres only. Drops the specified trigger.

    Parameters

    Returns Promise<void>

  • Get foreign key references details for the table

    Parameters

    Returns Promise<object>

  • getForeignKeysForTables(tableNames: string[], options?: QueryRawOptions): Promise<object>
  • Returns all foreign key constraints of requested tables

    Parameters

    Returns Promise<object>

  • Increments a row value

    Type parameters

    Parameters

    Returns Promise<object>

  • insert(instance: null | Model<any, any>, tableName: string, values: object, options?: QiInsertOptions): Promise<object>
  • Inserts a new record

    Parameters

    Returns Promise<object>

  • nameIndexes(indexes: string[], rawTablename: string): Promise<void>
  • Put a name to an index

    Parameters

    • indexes: string[]
    • rawTablename: string

    Returns Promise<void>

  • quoteIdentifier(identifier: string, force?: boolean): string
  • Escape an identifier (e.g. a table or attribute name). If force is true, the identifier will be quoted even if the quoteIdentifiers option is false.

    Parameters

    • identifier: string
    • Optional force: boolean

    Returns string

  • quoteIdentifiers(identifiers: string): string
  • Split an identifier into .-separated tokens and quote each part.

    Parameters

    • identifiers: string

    Returns string

  • Selects raw without parsing the string into an object

    Parameters

    Returns Promise<string[]>

  • Removes a column from a table

    Parameters

    Returns Promise<void>

  • Removes constraints from a table

    Parameters

    Returns Promise<void>

  • Removes an index of a table

    Parameters

    Returns Promise<void>

  • Parameters

    Returns Promise<void>

  • Renames a column

    Parameters

    Returns Promise<void>

  • Postgres only. Rename a function

    Parameters

    Returns Promise<void>

  • Renames a table

    Parameters

    Returns Promise<void>

  • Postgres only. Renames a trigger

    Parameters

    Returns Promise<void>

  • Rollback ( revert ) a transaction that has'nt been commited

    Parameters

    Returns Promise<void>

  • Returns selected rows

    Parameters

    Returns Promise<object[]>

  • Set option for autocommit of a transaction

    Parameters

    Returns Promise<void>

  • Set the isolation level of a transaction

    Parameters

    Returns Promise<void>

  • Queries all table names in the database.

    Parameters

    Returns Promise<object>

  • Returns all tables

    Parameters

    Returns Promise<string[]>

  • showIndex(tableName: string | object, options?: QueryRawOptions): Promise<object>
  • Shows the index of a table

    Parameters

    Returns Promise<object>

  • Begin a new transaction

    Parameters

    Returns Promise<void>

  • Updates a row

    Type parameters

    Parameters

    Returns Promise<object>

  • upsert<M>(tableName: TableName, insertValues: object, updateValues: object, where: object, options?: QiUpsertOptions<M>): Promise<object>
  • Inserts or Updates a record in the database

    Type parameters

    Parameters

    Returns Promise<object>

Generated using TypeDoc