query.pureFields() function
Narrows a requested fields map to the model's own columns.
Signature:
export function pureFields(model: typeof BaseModel, fields: any): string[] | true;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
model |
typeof BaseModel |
Model to narrow against. |
|
fields |
any |
Requested fields map, or a falsy value for "everything". |
Returns:
string[] | true
The surviving column names, or true meaning no restriction.
Remarks
Relations and unknown names are dropped, and the primary keys are then added back whether or not they were asked for — a deliberate trade so domain logic always has a key to work with, at the cost of returning a column the caller did not request.