Search...
bulkDeleteDraftPosts( )
Developer Preview
Deletes multiple draft posts.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function bulkDeleteDraftPosts(postIds: Array<string>, options: BulkDeleteDraftPostsOptions): Promise<BulkDeleteDraftPostsResponse>
bulkDeleteDraftPosts Parameters
NAME
TYPE
DESCRIPTION
postIds
Array<
string
>Post IDs.
options
Optional
BulkDeleteDraftPostsOptions
Options for deleting multiple draft posts.
Returns
Return Type:
Promise<
BulkDeleteDraftPostsResponse
>NAME
TYPE
DESCRIPTION
bulkActionMetadata
BulkActionMetadata
Bulk action metadata.
results
Array<
BulkDraftPostResult
>Bulk action results.
Was this helpful?
Bulk delete 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';45const elevatedBulkDeleteDraftPosts = elevate(draftPosts.bulkDeleteDraftPosts)67/*8 * Sample postIds value: ["448d1238-0072-4458-a280-bf81c2dd8af1", "d1c6418d-322b-4976-a815-80ee35c2a5e7"]9 *10 * Sample options value:11 *12 * {13 * "permanent": true14 * }15 */1617export const myBulkDeleteDraftPosts = webMethod(18 Permissions.Anyone,19 async (options) => {20 try {21 const draftPosts = await elevatedBulkDeleteDraftPosts(options);22 console.log('Deleted draft posts:', draftPosts)23 return draftPosts;24 } catch (error) {25 console.error(error);26 // Handle the error27 }28 }29);3031/* Promise resolves to:32 {33 "bulkActionMetadada": {34 "totalFailures": 0,35 "totalSuccesses": 2,36 "undetailedFailures": 037 },38 "results": [39 "item": {40 "categoryIds": [],41 "commentingEnabled": true,42 "featured": true,43 "language": "en",44 "media": {45 "custom": false,46 "displayed": true47 },48 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",49 "previewTextParagraph": 2,50 "pricingPlanIds": [],51 "relatedPostIds": [],52 "richContent": {53 "nodes": [54 {55 "type": "PARAGRAPH",56 "id": "pvirv1",57 "nodes": [58 {59 "type": "TEXT",60 "id": "",61 "nodes": [],62 "textData": {63 "text": "Hello world",64 "decorations": []65 }66 }67 ],68 "paragraphData": {}69 }70 ],71 }72 "seoData": {73 "tags": []74 "},75 "seoSlug": "hello-world",76 "tagIds": [],77 "title": "Hello, world"78 },79 "item": {80 "categoryIds": [],81 "commentingEnabled": true,82 "featured": true,83 "language": "en",84 "media": {85 "custom": false,86 "displayed": true87 },88 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",89 "previewTextParagraph": 2,90 "pricingPlanIds": [],91 "relatedPostIds": [],92 "richContent": {93 "nodes": [94 {95 "type": "PARAGRAPH",96 "id": "pvirv1",97 "nodes": [98 {99 "type": "TEXT",100 "id": "",101 "nodes": [],102 "textData": {103 "text": "Hello to you too",104 "decorations": []105 }106 }107 ],108 "paragraphData": {}109 }110 ],111 }112 "seoData": {113 "tags": []114 "},115 "seoSlug": "hello-to-you-too",116 "tagIds": [],117 "title": "Hello to you too"118 }119 ]120 }121*/
Bulk delete draft posts (dashboard page code)
Copy Code
1import { draftPosts } from 'wix-blog-backend';23/*4 * Sample postIds value: ["448d1238-0072-4458-a280-bf81c2dd8af1", "d1c6418d-322b-4976-a815-80ee35c2a5e7"]5 *6 * Sample options value:7 *8 * {9 * "permanent": true10 * }11 */1213export async const myBulkDeleteDraftPosts(options) => {14 try {15 const draftPosts = await draftPosts.bulkDeleteDraftPosts(options);16 console.log('Deleted draft posts:', draftPosts)17 return draftPosts;18 } catch (error) {19 console.error(error);20 // Handle the error21 }22 };2324/* Promise resolves to:25 {26 "bulkActionMetadada": {27 "totalFailures": 0,28 "totalSuccesses": 2,29 "undetailedFailures": 030 },31 "results": [32 "item": {33 "categoryIds": [],34 "commentingEnabled": true,35 "featured": true,36 "language": "en",37 "media": {38 "custom": false,39 "displayed": true40 },41 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",42 "previewTextParagraph": 2,43 "pricingPlanIds": [],44 "relatedPostIds": [],45 "richContent": {46 "nodes": [47 {48 "type": "PARAGRAPH",49 "id": "pvirv1",50 "nodes": [51 {52 "type": "TEXT",53 "id": "",54 "nodes": [],55 "textData": {56 "text": "Hello world",57 "decorations": []58 }59 }60 ],61 "paragraphData": {}62 }63 ],64 }65 "seoData": {66 "tags": []67 "},68 "seoSlug": "hello-world",69 "tagIds": [],70 "title": "Hello, world"71 },72 "item": {73 "categoryIds": [],74 "commentingEnabled": true,75 "featured": true,76 "language": "en",77 "media": {78 "custom": false,79 "displayed": true80 },81 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",82 "previewTextParagraph": 2,83 "pricingPlanIds": [],84 "relatedPostIds": [],85 "richContent": {86 "nodes": [87 {88 "type": "PARAGRAPH",89 "id": "pvirv1",90 "nodes": [91 {92 "type": "TEXT",93 "id": "",94 "nodes": [],95 "textData": {96 "text": "Hello to you too",97 "decorations": []98 }99 }100 ],101 "paragraphData": {}102 }103 ],104 }105 "seoData": {106 "tags": []107 "},108 "seoSlug": "hello-to-you-too",109 "tagIds": [],110 "title": "Hello to you too"111 }112 ]113 }114*/