diff --git a/content/guides/04.connect/3.query-parameters.md b/content/guides/04.connect/3.query-parameters.md index 59e33434..41ba642f 100644 --- a/content/guides/04.connect/3.query-parameters.md +++ b/content/guides/04.connect/3.query-parameters.md @@ -535,13 +535,20 @@ Saves the API response to a file. Valid values are `csv`, `json`, `xml`, `yaml`. ## Version -Queries a version of a record by version key when [content versioning](/guides/content/content-versioning) is enabled on a collection. Applies only to single item retrieval. +Queries a version of a record by version key when [content versioning](/guides/content/content-versioning) is enabled on a collection. -```http [GET /items/posts/1] -?version=v1 +```http +GET /items/posts?version=v1 +GET /items/posts/1?version=v1 ``` ```graphql [GraphQL] +query { + posts(version: "v1") { + id + } +} + query { posts_by_id(id: 1, version: "v1") { id @@ -554,15 +561,25 @@ import { createDirectus, rest, readItem } from "@directus/sdk"; const directus = createDirectus("https://directus.example.com").with(rest()); const result = await directus.request( + readItems("posts", { + version: "v1", + }) +); + +const item = await directus.request( readItem("posts", { version: "v1", }) ); ``` +### Version Meta + +When retrieving a versioned item, an additional `$meta` field is included in the response, containing metadata such as the version key, the used delta and possibly an error message if the version failed to apply. + ## VersionRaw -Specifies to return relational delta changes as a [detailed output](https://directus.io/docs/guides/connect/relations#creating-updating-deleting) on a version record. +Specifies to return relational delta changes as a [detailed output](https://directus.io/docs/guides/connect/relations#creating-updating-deleting) on a version record. Applies only to single item retrieval. ```http [GET /items/posts/1] ?version=v1&versionRaw=true @@ -736,4 +753,4 @@ The articles collection consists of a many-to-one relation to Users called `auth } ``` -:: \ No newline at end of file +::