# Sequelize.query() method · @imqueue/pg-sequelize

Source: https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.sequelize.query/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-sequelize 4.2.0 — generated reference, not hand-written

Runs a raw statement, honouring a `returning` column list.

**Signature:**

```typescript
query(sqlQuery: string | {
        query: string;
        values: any[];
    }, options?: QueryOptions | QueryOptionsWithType<QueryTypes.RAW>): Promise<any>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| sqlQuery | string \| { query: string; values: any\[\]; } | The statement, or a statement with its bind values. |
| options | [QueryOptions](https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.queryoptions/) \| QueryOptionsWithType<QueryTypes.RAW> | _(Optional)_ Query options, where `returning` may be a column list. |


**Returns:**

Promise<any>

Whatever sequelize's own `query()` returns for these options.

## Remarks

Given a non-empty `returning` array, the `RETURNING *` in the statement is rewritten to name exactly those columns, and every returned model instance remembers the list, so serializing it emits only those properties. Everything else is sequelize's own `query()`.

The rewrite is textual and looks for `RETURNING *` specifically, so a statement that already names its columns is left alone — and one that has no `RETURNING` at all is not given one.

