Local API
To specifyselect in the Local API, you can use the select option in your query:
Empty select
Theid field is always included in the result, regardless of your select query. If you pass an empty select object, only the id will be returned:
Entity-level select config
Collections and globals accept a top-levelselect function that runs before every read and returns the select to apply, replacing the caller’s. It receives { operation, req, select }; return undefined to keep the caller’s select.
Use it to make sure hooks and access control always get a field, or to send admin requests less data than API requests. The function runs before the read, so it can’t see the document.
select instead of merging with it, so spread the caller’s select in when you only want to add fields.
REST API
To specify select in the REST API, you can use theselect parameter in your query:
qs-esm package to parse your JSON / object-formatted queries into query strings:
defaultPopulate collection config property
ThedefaultPopulate property allows you specify which fields to select when populating the collection from another document.
This is especially useful for links where only the slug is needed instead of the entire document.
With this feature, you can dramatically reduce the amount of JSON populated from Relationship or Upload fields.
For example, in your content model, you might have a Link field which links out to a different page. When you go to retrieve these links, you really only need the slug of the page.
Loading all of the page content, its related links, and everything else is going to be overkill and will bog down your FrogBot APIs. Instead, you can define the defaultPopulate property on your Pages collection, so that when FrogBot “populates” a related Page, it only selects the slug field and therefore returns significantly less JSON:
Populate
SettingdefaultPopulate will enforce that each time FrogBot performs a “population” of a related document, only the fields specified will be queried and returned. However, you can override defaultPopulate with the populate property in the Local and REST API:
Local API: