Method sets rules for partial loading of fields for the collection items.
The __id field is always returned in the result.
__id
Specify true for the fields which values you want to retrieve. Other fields will be excluded from the result.
true
.fields({ name: true, email: true }) // Returns only the values of the `name` and `email` fields, as well as the `__id`
Specify false for the fields which values you do not need. Other fields will be included in the result.
false
.fields ({ email: false, role: false }) // Returns all fields, except for `email` and `role`
You can use true and false together, but true has the priority.
.fields ({ role: true, name: true, email: false }) // Returns only `role` and `name` , as well as `__id`
Defined search rules with field restrictions applied in the first() и all()methods.
first()
all()
Your review is successfully sent!
Feedback sent successfully
ApplicationSearch extension: partial loading of fields
Type parameters
T: ItemData
P: ItemData
Hierarchy
Methods
fields
Method sets rules for partial loading of fields for the collection items.
The
__idfield is always returned in the result.Selecting fields for partial loading
Specify
truefor the fields which values you want to retrieve. Other fields will be excluded from the result..fields({ name: true, email: true }) // Returns only the values of the `name` and `email` fields, as well as the `__id`Excluding fields from the result
Specify
falsefor the fields which values you do not need. Other fields will be included in the result..fields ({ email: false, role: false }) // Returns all fields, except for `email` and `role`Combination of partial loading rules
You can use
trueandfalsetogether, buttruehas the priority..fields ({ role: true, name: true, email: false }) // Returns only `role` and `name` , as well as `__id`Type parameters
S: FieldSelection<T>
Parameters
selector: ValidateFields<T, S>
Returns ApplicationSearchWithProjection<T, P, S>
Defined search rules with field restrictions applied in the
first()иall()methods.