_id and those fields, nothing else.
Name the fields
fields=title,slug on any list.Every document, in the SDKs
…Pick() walks every page for you.Which id to send
Published or draft, and why it matters.
Name the fields
Every content type’s list, and the page tree, takefields: the fields to answer beside each
document’s _id.
fields=title&fields=slug, or fields=title,slug. At most 50. A field the type doesn’t have is
refused with 400, and the message lists the fields it has.Terminal
page, perPage), search and filters:
Terminal
The page tree keeps its shape
The page tree keeps its shape
Without
flat=1 the page tree answers the home page with its pages nested under _children.
With fields, every page in the tree is trimmed the same way, and _children stays, so the tree
is still a tree. In a flat list each page names its children by id: ask for _children to keep
them.Fields with an underscore
Fields with an underscore
Some fields are worked out when the document is read:
_url (its address on the site) and the
related documents (_author, _category …). Name them like any other field.An API key without the type's read scope
An API key without the type's read scope
A key without the type’s read scope reads only the fields the site makes public, and may name only
those: any other is refused with
400, listing the public ones. A key with the read scope may name
any field (Required scopes).Every document, in the SDKs
Every list method that takesfields has a …Pick() twin. It walks every page of the list for you,
100 documents a page, and answers one plain row per document: its id, then each field you named.
Rows, not models
A row holds only what you asked for, so it isn’t the type’s model: it’s a plain array (Laravel) or
object (TypeScript), with each value as the site sends it (a date is its ISO text).
The SDK's names
Name a field as the SDK does (
url) or as the site does (_url); the row always uses the SDK’s
name. A field the type doesn’t have throws before anything is sent.The list's own filters
…Pick() takes its list’s arguments, bar the page: search, slug, aposMode, perPage …Fakes answer it too
It records the list’s own key, so a test fakes
blogPosts.listBlogs and asserts that.Find one
- By its slug
- A page
- By its text
Every list but the page tree finds one document by its slug, so only that one comes back:
id to the call that wants it:
Which id to send
An id names its document’s locale and mode:ckq3v8x5b0002:en:published is the published copy,
ckq3v8x5b0002:en:draft its draft. A list answers the copies of the mode it reads, so pick the mode
you will work on:
To read what visitors see
The default list answers published ids.
To change a draft
List with
aposMode: 'draft' (aposMode=draft): its ids are the drafts’. A draft read needs the
type’s write scope.…Pick() call under Find the id.
Related
Lists and paging
How every list pages, and the
…All() walks.Call from the terminal
Any method,
…Pick() included, with one Artisan command.