An abstract class that Sequelize uses to add query support for a dialect.

This interface is only exposed when running before/afterQuery lifecycle events.

Constructors

Properties

connection: AbstractConnection

A Sequelize connection instance.

instance: Model<any, any>

If provided, returns the model instance.

Model type definition.

sequelize: Sequelize<AbstractDialect<object, object>>

Returns the current sequelize instance.

sql: string

The SQL being executed by this Query.

uuid: unknown

Returns a unique identifier assigned to a query internally by Sequelize.

Methods

  • Protected

    Parameters

    • sql: string
    • debugContext: ((msg) => any)
        • (msg): any
        • Parameters

          • msg: string

          Returns any

    • parameters: unknown[] | Record<string, unknown>

    Returns (() => void)

    A function to call after the query was completed.

      • (): void
      • Returns void

  • Private

    Returns the unique constraint error message for the associated field.

    Parameters

    • field: string

      the field name associated with the unique constraint.

    Returns string

    The unique constraint error message.

  • Private

    The function takes the result of the query execution and groups the associated data by the callee.

    Parameters

    Returns unknown[]

    Example

    groupJoinData([
    {
    some: 'data',
    id: 1,
    association: { foo: 'bar', id: 1 }
    }, {
    some: 'data',
    id: 1,
    association: { foo: 'bar', id: 2 }
    }, {
    some: 'data',
    id: 1,
    association: { foo: 'bar', id: 3 }
    }
    ]);

    Results in:

    [
    {
    some: 'data',
    id: 1,
    association: [
    { foo: 'bar', id: 1 },
    { foo: 'bar', id: 2 },
    { foo: 'bar', id: 3 }
    ]
    }
    ]