query.filtered() function
Intersects a set of attributes with the names a caller asked for.
Signature:
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 |
(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.