# ReturningOptions interface · @imqueue/pg-sequelize

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

Widens `returning` so it can name the columns to fetch back, not just ask whether to fetch any.

**Signature:**

```typescript
export interface ReturningOptions 
```

## Remarks

Sequelize types `returning` as a boolean: every column, or none. Postgres can return a subset, and a service usually wants exactly the fields its caller asked for — so this package accepts a list of column names and rewrites the `RETURNING *` in the generated statement to name just those.

Two things follow. Less data crosses both hops: the database returns fewer columns, and the instance remembers the list, so serializing it emits only those properties. And because the option is widened rather than replaced, `true` and `false` keep working exactly as before. An empty array is treated as `false`, since a statement returning no columns is not what anyone means by it.

The cost is a cast at the call site, and the mimicked option types in this module are what to cast to — they exist for this and nothing else. Whenever TypeScript objects to a `returning` array, import the type it names from `@imqueue/pg-sequelize` rather than from `sequelize`. Use `restoreSerialization()` to forget the list again.

## Example


```typescript
const scope = new Scope({ name: 'test', description: 'Test', schema: {} });

await scope.save({ returning: ['id', 'name'] } as SaveOptions);
console.log(JSON.stringify(scope)); // {"id":2,"name":"test"}

const [count, scopes] = await Scope.update({ name: 'TEST' }, {
    where: { id: 2 },
    returning: ['id', 'name'],
} as UpdateOptions);
console.log(JSON.stringify(scopes[0])); // {"id":2,"name":"TEST"}
```

## Properties


| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [returning?](https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.returningoptions.returning/) |  | boolean \| string\[\] | _(Optional)_ `true` for every column, `false` for none, or the names of the columns to fetch back. |

