Querying a Single Document
Querying a single document
Get a single document, providing it's relativePath as the argument.
relativePathis the portion of the path relative to thecollection's path.
In this example, the post collection has a path of content/posts and your document can be found at content/posts/voteForPedro.md giving relativePath: "voteForPedro.md". If your item was at content/posts/nested-folder/voteForPedro.md you'd specify: relativePath: "nested-folder/voteForPedro.md".
Our collections for the above schema are named "post" and "author", so we can query for each using the post & author
Examples
Query on author only.
Query on post and author.
Query post on author.
Common fields
In a collection, there are a few fields that are common to all documents. These are: id, _values and _sys. The id field is a unique identifier for the document. The _values field is used internally in edit mode and is not for external use. The _sys field contains meta information about the document.
The _sys field is an object with the following fields:
The name of the file without the extension
The name of the file with the extension
The full path of the file relative to the project root
An array of the parent folders of the file
The path of the file relative to the collection path
The extension of the file
The template of the document (or the name of the collection if not using templates)
Information about the collection