-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Expand file tree
/
Copy pathget-document.mjs
More file actions
42 lines (40 loc) · 914 Bytes
/
get-document.mjs
File metadata and controls
42 lines (40 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sanity from "../../sanity.app.mjs";
export default {
key: "sanity-get-document",
name: "Get Document",
description: "Get a document from a dataset in Sanity. [See the documentation](https://www.sanity.io/docs/http-reference/doc#getDocuments)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
sanity,
dataset: {
propDefinition: [
sanity,
"dataset",
],
},
documentId: {
propDefinition: [
sanity,
"documentId",
({ dataset }) => ({
dataset,
}),
],
},
},
async run({ $ }) {
const response = await this.sanity.getDocument({
$,
dataset: this.dataset,
documentId: this.documentId,
});
$.export("$summary", "Successfully retrieved document");
return response;
},
};