Search.../

bulkUpdateDraftPosts( )

Updates multiple draft posts.

Syntax

function bulkUpdateDraftPosts(options: BulkUpdateDraftPostsOptions): Promise<BulkUpdateDraftPostsResponse>

bulkUpdateDraftPosts Parameters

NAME
TYPE
DESCRIPTION
options
Optional
BulkUpdateDraftPostsOptions

Options for updating multiple draft posts.

Returns

Return Type:

Promise<
BulkUpdateDraftPostsResponse
>
NAME
TYPE
DESCRIPTION
bulkActionMetadata
BulkActionMetadata

Bulk action metadata.

results
Array<
BulkDraftPostResult
>

Draft posts updated by bulk action.

Was this helpful?

Bulk update draft posts (export from backend code)

Copy Code
1import { draftPosts } from 'wix-blog-backend';
2import { webMethod, Permissions } from 'wix-web-module';
3import { elevate } from 'wix-auth';
4
5const elevatedBulkUpdateDraftPosts = elevate(draftPosts.bulkUpdateDraftPosts)
6
7/* Sample options value:
8 * {
9 * "action": "UPDATE_PUBLISH",
10 * "draftPosts": [
11 * "draftPost": {
12 * "id": "448d1238-0072-4458-a280-bf81c2dd8af1",
13 * "title": "Hello, world"
14 * },
15 * "draftPost": {
16 * "id": "d1c6418d-322b-4976-a815-80ee35c2a5e7",
17 * "title": "Hello to you too"
18 * },
19 * ]
20 * }
21*/
22
23export const myBulkUpdateDraftPosts = webMethod(
24 Permissions.Anyone,
25 async (options) => {
26 try {
27 const draftPosts = await elevatedBulkUpdateDraftPosts(options);
28 console.log('Updated draft posts:', draftPosts)
29 return draftPosts;
30 } catch (error) {
31 console.error(error);
32 // Handle the error
33 }
34 }
35);
36
37/* Promise resolves to:
38 {
39 "bulkActionMetadada": {
40 "totalFailures": 0,
41 "totalSuccesses": 2,
42 "undetailedFailures": 0
43 },
44 "results": [
45 "item": {
46 "categoryIds": [],
47 "commentingEnabled": true,
48 "featured": true,
49 "language": "en",
50 "media": {
51 "custom": false,
52 "displayed": true
53 },
54 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
55 "previewTextParagraph": 2,
56 "pricingPlanIds": [],
57 "relatedPostIds": [],
58 "richContent": {
59 "nodes": [
60 {
61 "type": "PARAGRAPH",
62 "id": "pvirv1",
63 "nodes": [
64 {
65 "type": "TEXT",
66 "id": "",
67 "nodes": [],
68 "textData": {
69 "text": "Hello world",
70 "decorations": []
71 }
72 }
73 ],
74 "paragraphData": {}
75 }
76 ],
77 }
78 "seoData": {
79 "tags": []
80 "},
81 "seoSlug": "hello-world",
82 "tagIds": [],
83 "title": "Hello, world"
84 },
85 "item": {
86 "categoryIds": [],
87 "commentingEnabled": true,
88 "featured": true,
89 "language": "en",
90 "media": {
91 "custom": false,
92 "displayed": true
93 },
94 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
95 "previewTextParagraph": 2,
96 "pricingPlanIds": [],
97 "relatedPostIds": [],
98 "richContent": {
99 "nodes": [
100 {
101 "type": "PARAGRAPH",
102 "id": "pvirv1",
103 "nodes": [
104 {
105 "type": "TEXT",
106 "id": "",
107 "nodes": [],
108 "textData": {
109 "text": "Hello to you too",
110 "decorations": []
111 }
112 }
113 ],
114 "paragraphData": {}
115 }
116 ],
117 }
118 "seoData": {
119 "tags": []
120 "},
121 "seoSlug": "hello-to-you-too",
122 "tagIds": [],
123 "title": "Hello to you too"
124 }
125 ]
126 }
127*/
Bulk update draft posts

Copy Code
1import { draftPosts } from 'wix-blog-backend';
2
3/* Sample options value:
4 * {
5 * "action": "UPDATE_PUBLISH",
6 * "draftPosts": [
7 * "draftPost": {
8 * "id": "448d1238-0072-4458-a280-bf81c2dd8af1",
9 * "title": "Hello, world"
10 * },
11 * "draftPost": {
12 * "id": "d1c6418d-322b-4976-a815-80ee35c2a5e7",
13 * "title": "Hello to you too"
14 * },
15 * ]
16 * }
17*/
18
19export async const myBulkUpdateDraftPosts(options) => {
20 try {
21 const draftPosts = await draftPosts.bulkUpdateDraftPosts(options);
22 console.log('Updated draft posts:', draftPosts)
23 return draftPosts;
24 } catch (error) {
25 console.error(error);
26 // Handle the error
27 }
28 };
29
30/* Promise resolves to:
31 {
32 "bulkActionMetadada": {
33 "totalFailures": 0,
34 "totalSuccesses": 2,
35 "undetailedFailures": 0
36 },
37 "results": [
38 "item": {
39 "categoryIds": [],
40 "commentingEnabled": true,
41 "featured": true,
42 "language": "en",
43 "media": {
44 "custom": false,
45 "displayed": true
46 },
47 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
48 "previewTextParagraph": 2,
49 "pricingPlanIds": [],
50 "relatedPostIds": [],
51 "richContent": {
52 "nodes": [
53 {
54 "type": "PARAGRAPH",
55 "id": "pvirv1",
56 "nodes": [
57 {
58 "type": "TEXT",
59 "id": "",
60 "nodes": [],
61 "textData": {
62 "text": "Hello world",
63 "decorations": []
64 }
65 }
66 ],
67 "paragraphData": {}
68 }
69 ],
70 }
71 "seoData": {
72 "tags": []
73 "},
74 "seoSlug": "hello-world",
75 "tagIds": [],
76 "title": "Hello, world"
77 },
78 "item": {
79 "categoryIds": [],
80 "commentingEnabled": true,
81 "featured": true,
82 "language": "en",
83 "media": {
84 "custom": false,
85 "displayed": true
86 },
87 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
88 "previewTextParagraph": 2,
89 "pricingPlanIds": [],
90 "relatedPostIds": [],
91 "richContent": {
92 "nodes": [
93 {
94 "type": "PARAGRAPH",
95 "id": "pvirv1",
96 "nodes": [
97 {
98 "type": "TEXT",
99 "id": "",
100 "nodes": [],
101 "textData": {
102 "text": "Hello to you too",
103 "decorations": []
104 }
105 }
106 ],
107 "paragraphData": {}
108 }
109 ],
110 }
111 "seoData": {
112 "tags": []
113 "},
114 "seoSlug": "hello-to-you-too",
115 "tagIds": [],
116 "title": "Hello to you too"
117 }
118 ]
119 }
120*/