# query.filtered() function · @imqueue/pg-sequelize

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

Intersects a set of attributes with the names a caller asked for.

**Signature:**

```typescript
export function filtered(attributes: any, fields: string[], model?: typeof BaseModel): string[];
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| attributes | any | Object whose keys are the available names. |
| fields | string\[\] | Names the caller asked for. |
| model | typeof [BaseModel](https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.basemodel/) | _(Optional)_ Model to take primary keys from when nothing matched. |


**Returns:**

string\[\]

The matching names, or the primary keys, or an empty array.

## Remarks

With a `model` given, an empty intersection falls back to that model's primary keys rather than to nothing — so a fields list that matches no column selects the keys instead of every column, which is the safer failure but is not what "no matches" might suggest. Without a `model`, an empty result stays empty.

