Search.../

listDeletedDraftPosts( )

Retrieves a list of up to 100 deleted draft posts.

Description

List Deleted Draft Posts runs with these defaults, which you can override:

  • editedDate is sorted in descending order. In this case,editedDate implies the date the post was deleted.
  • paging.limit is 50.
  • paging.offset is 0.
Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function listDeletedDraftPosts(options: ListDeletedDraftPostsOptions): Promise<ListDeletedDraftPostsResponse>

listDeletedDraftPosts Parameters

NAME
TYPE
DESCRIPTION
options
Optional
ListDeletedDraftPostsOptions

Options for listing deleted draft posts.

Returns

Return Type:

Promise<
ListDeletedDraftPostsResponse
>
NAME
TYPE
DESCRIPTION
draftPosts
Array<
DraftPost
>

List of draft posts.

metaData
MetaData

Details on the paged set of results returned.

Was this helpful?

List deleted draft posts (dashboard page code)

Copy Code
1import { draftPosts } from 'wix-blog-backend';
2
3export async function myListDeletedDraftPostFunction() {
4 try {
5 const deletedDraftPost = await draftPosts.listDeletedDraftPosts();
6 console.log('Successfully retrieved the following deleted draft posts:', deletedDraftPost);
7 return deletedDraftPost;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13
14/* Promise resolves to:
15 * {
16 * "draftPosts": [
17 * {
18 * "_id": "425a5dca-c32d-40e6-b2d7-a8ffa3addded",
19 * "_createdDate": "2023-08-13T13:51:23.823Z",
20 * "categoryIds": [],
21 * "changeOrigin": "MOVE_TO_TRASH",
22 * "commentingEnabled": true,
23 * "contentId": "65af9595676f8c78e7e808e7",
24 * "coverMedia": {
25 * "custom": false,
26 * "displayed": true,
27 * "enabled": true,
28 * "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
29 * },
30 * "editedDate": "2024-01-23T10:31:49.017Z",
31 * "featured": false,
32 * "firstPublishedDate": "2023-03-22T14:16:01.200Z",
33 * "hashtags": [
34 * "vacation",
35 * "dream",
36 * "summer",
37 * "hashtag"
38 * ],
39 * "hasUnpublishedChanges": true,
40 * "language": "en",
41 * "media": {
42 * "custom": false,
43 * "displayed": true,
44 * "wixMedia": {
45 * "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
46 * }
47 * },
48 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
49 * "minutesToRead": 2,
50 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
51 * "pricingPlanIds": [],
52 * "relatedPostIds": [],
53 * "seoData": {
54 * "tags": []
55 * },
56 * "seoSlug": "when-expecting-expect-the-unexpected",
57 * "slugs": [],
58 * "status": "DELETED",
59 * "tagIds": [],
60 * "title": "When expecting, expect the unexpected",
61 * "translations": []
62 * },
63 * {
64 * "_id": "2b36fbd0-f87a-43ce-ad11-e73d354b0072",
65 * "_createdDate": "2024-01-08T16:16:29.630Z",
66 * "categoryIds": [],
67 * "changeOrigin": "MOVE_TO_TRASH",
68 * "commentingEnabled": true,
69 * "contentId": "659c2017e7b862a68364f0bd",
70 * "editedDate": "2024-01-08T16:21:30.639Z",
71 * "editingSessionId": "760338e1-3e8d-4377-8aa4-cebf0763827f",
72 * "featured": false,
73 * "hashtags": [],
74 * "hasUnpublishedChanges": true,
75 * "language": "en",
76 * "media": {
77 * "custom": false,
78 * "displayed": true,
79 * "wixMedia": {
80 * "image": "wix:image://v1/nsplsh_e24d88fb732446e48d71951b09c571e8~mv2.jpg/a%20man%20with%20a%20lot%20of%20tattoos%20on%20his%20chest.jpg#originWidth=3818&originHeight=4772"
81 * }
82 * },
83 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
84 * "minutesToRead": 1,
85 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
86 * "pricingPlanIds": [],
87 * "relatedPostIds": [],
88 * "seoData": {
89 * "settings": {
90 * "keywords": [],
91 * "preventAutoRedirect": false
92 * },
93 * "tags": []
94 * },
95 * "slugs": [],
96 * "status": "DELETED",
97 * "tagIds": [],
98 * "title": "When we stand together",
99 * "translations": []
100 * },
101 * {
102 * "_id": "66935097-31c5-4fab-9693-aa1b53aeea77",
103 * "_createdDate": "2024-01-07T08:39:26.900Z",
104 * "categoryIds": [],
105 * "changeOrigin": "MOVE_TO_TRASH",
106 * "commentingEnabled": true,
107 * "contentId": "659a6364bb866d6c2d674b4d",
108 * "coverMedia": {
109 * "custom": false,
110 * "displayed": true,
111 * "enabled": true,
112 * "image": "wix:image://v1/11062b_9874b9821b9a4c92a07b1349883fbc42~mv2_d_3000_4507_s_4_2.jpg#originWidth=3000&originHeight=4507"
113 * },
114 * "editedDate": "2024-01-07T08:40:08.655Z",
115 * "editingSessionId": "1a140780-9d07-4d18-b914-a6d69c313879",
116 * "featured": false,
117 * "hashtags": [],
118 * "hasUnpublishedChanges": true,
119 * "language": "en",
120 * "media": {
121 * "custom": false,
122 * "displayed": true,
123 * "wixMedia": {
124 * "image": "wix:image://v1/11062b_9874b9821b9a4c92a07b1349883fbc42~mv2_d_3000_4507_s_4_2.jpg#originWidth=3000&originHeight=4507"
125 * }
126 * },
127 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
128 * "minutesToRead": 1,
129 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
130 * "pricingPlanIds": [],
131 * "relatedPostIds": [],
132 * "seoData": {
133 * "tags": []
134 * },
135 * "slugs": [],
136 * "status": "DELETED",
137 * "tagIds": [],
138 * "title": "This is a draft",
139 * "translations": []
140 * }
141 * ],
142 * "metaData": {
143 * "count": 3,
144 * "offset": 0,
145 * "total": 3
146 * }
147 * }
148 */
List deleted draft posts using options (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
5/*
6 * Sample options value:
7 * {
8 * draftPostIds: ["425a5dca-c32d-40e6-b2d7-a8ffa3addded", "5fb8b42a-42e1-4c77-92e7-46d93cf4ad0b"],
9 * fieldsets: ["GENERATED_EXCERPT"],
10 * language: "en",
11 * paging: {
12 * cursor: "",
13 * limit: 2,
14 * offset: 0
15 * },
16 * sort: "EDITING_DATE_ASC"
17 * }
18 */
19
20const elevatedListDraftPost = elevate(draftPosts.listDraftPosts);
21
22export const myListDeletedDraftPostFunction = webMethod(
23 Permissions.Admin,
24 async (options) => {
25 try {
26 const deletedDraftPost = await elevatedListDraftPost(options);
27 console.log('Successfully retrieved the following deleted draft posts:', deletedDraftPost);
28 return deletedDraftPost;
29 } catch (error) {
30 console.error(error);
31 // Handle the error
32 }
33 }
34);
35
36/* Promise resolves to:
37 * {
38 * "draftPosts": [
39 * {
40 * "_id": "66935097-31c5-4fab-9693-aa1b53aeea77",
41 * "_createdDate": "2024-01-07T08:39:26.900Z",
42 * "categoryIds": [],
43 * "changeOrigin": "MOVE_TO_TRASH",
44 * "commentingEnabled": true,
45 * "contentId": "659a6364bb866d6c2d674b4d",
46 * "coverMedia": {
47 * "custom": false,
48 * "displayed": true,
49 * "enabled": true,
50 * "image": "wix:image://v1/11062b_9874b9821b9a4c92a07b1349883fbc42~mv2_d_3000_4507_s_4_2.jpg#originWidth=3000&originHeight=4507"
51 * },
52 * "editedDate": "2024-01-07T08:40:08.655Z",
53 * "editingSessionId": "1a140780-9d07-4d18-b914-a6d69c313879",
54 * "excerpt": "Testing the DraftPosts API",
55 * "featured": false,
56 * "hashtags": [],
57 * "hasUnpublishedChanges": true,
58 * "language": "en",
59 * "media": {
60 * "custom": false,
61 * "displayed": true,
62 * "wixMedia": {
63 * "image": "wix:image://v1/11062b_9874b9821b9a4c92a07b1349883fbc42~mv2_d_3000_4507_s_4_2.jpg#originWidth=3000&originHeight=4507"
64 * }
65 * },
66 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
67 * "minutesToRead": 1,
68 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
69 * "pricingPlanIds": [],
70 * "relatedPostIds": [],
71 * "seoData": {
72 * "tags": []
73 * },
74 * "slugs": [],
75 * "status": "DELETED",
76 * "tagIds": [],
77 * "title": "This is a draft",
78 * "translations": []
79 * },
80 * {
81 * "_id": "2b36fbd0-f87a-43ce-ad11-e73d354b0072",
82 * "_createdDate": "2024-01-08T16:16:29.630Z",
83 * "categoryIds": [],
84 * "changeOrigin": "MOVE_TO_TRASH",
85 * "commentingEnabled": true,
86 * "contentId": "659c2017e7b862a68364f0bd",
87 * "editedDate": "2024-01-08T16:21:30.639Z",
88 * "editingSessionId": "760338e1-3e8d-4377-8aa4-cebf0763827f",
89 * "excerpt": "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled...",
90 * "featured": false,
91 * "hashtags": [],
92 * "hasUnpublishedChanges": true,
93 * "language": "en",
94 * "media": {
95 * "custom": false,
96 * "displayed": true,
97 * "wixMedia": {
98 * "image": "wix:image://v1/nsplsh_e24d88fb732446e48d71951b09c571e8~mv2.jpg/a%20man%20with%20a%20lot%20of%20tattoos%20on%20his%20chest.jpg#originWidth=3818&originHeight=4772"
99 * }
100 * },
101 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
102 * "minutesToRead": 1,
103 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
104 * "pricingPlanIds": [],
105 * "relatedPostIds": [],
106 * "seoData": {
107 * "settings": {
108 * "keywords": [],
109 * "preventAutoRedirect": false
110 * },
111 * "tags": []
112 * },
113 * "slugs": [],
114 * "status": "DELETED",
115 * "tagIds": [],
116 * "title": "When we stand together",
117 * "translations": []
118 * }
119 * ],
120 * "metaData": {
121 * "count": 2,
122 * "offset": 0,
123 * "total": 3
124 * }
125 * }
126 */
127
List deleted 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 elevatedListDeletedDraftPost = elevate(draftPosts.listDeletedDraftPosts);
6
7export const myListDeletedDraftPostFunction = webMethod(
8 Permissions.Admin,
9 async () => {
10 try {
11 const deletedDraftPost = await elevatedListDeletedDraftPost();
12 console.log('Successfully retrieved the following deleted draft posts:', deletedDraftPost);
13 return deletedDraftPost;
14 } catch (error) {
15 console.error(error);
16 // Handle the error
17 }
18 }
19);
20/* Promise resolves to:
21 * {
22 * "draftPosts": [
23 * {
24 * "_id": "425a5dca-c32d-40e6-b2d7-a8ffa3addded",
25 * "_createdDate": "2023-08-13T13:51:23.823Z",
26 * "categoryIds": [],
27 * "changeOrigin": "MOVE_TO_TRASH",
28 * "commentingEnabled": true,
29 * "contentId": "65af9595676f8c78e7e808e7",
30 * "coverMedia": {
31 * "custom": false,
32 * "displayed": true,
33 * "enabled": true,
34 * "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
35 * },
36 * "editedDate": "2024-01-23T10:31:49.017Z",
37 * "featured": false,
38 * "firstPublishedDate": "2023-03-22T14:16:01.200Z",
39 * "hashtags": [
40 * "vacation",
41 * "dream",
42 * "summer",
43 * "hashtag"
44 * ],
45 * "hasUnpublishedChanges": true,
46 * "language": "en",
47 * "media": {
48 * "custom": false,
49 * "displayed": true,
50 * "wixMedia": {
51 * "image": "wix:image://v1/75059a_9f8cd2f1282c4dc7ae9a4bea155e2661~mv2.jpg#originWidth=602&originHeight=773"
52 * }
53 * },
54 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
55 * "minutesToRead": 2,
56 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
57 * "pricingPlanIds": [],
58 * "relatedPostIds": [],
59 * "seoData": {
60 * "tags": []
61 * },
62 * "seoSlug": "when-expecting-expect-the-unexpected",
63 * "slugs": [],
64 * "status": "DELETED",
65 * "tagIds": [],
66 * "title": "When expecting, expect the unexpected",
67 * "translations": []
68 * },
69 * {
70 * "_id": "2b36fbd0-f87a-43ce-ad11-e73d354b0072",
71 * "_createdDate": "2024-01-08T16:16:29.630Z",
72 * "categoryIds": [],
73 * "changeOrigin": "MOVE_TO_TRASH",
74 * "commentingEnabled": true,
75 * "contentId": "659c2017e7b862a68364f0bd",
76 * "editedDate": "2024-01-08T16:21:30.639Z",
77 * "editingSessionId": "760338e1-3e8d-4377-8aa4-cebf0763827f",
78 * "featured": false,
79 * "hashtags": [],
80 * "hasUnpublishedChanges": true,
81 * "language": "en",
82 * "media": {
83 * "custom": false,
84 * "displayed": true,
85 * "wixMedia": {
86 * "image": "wix:image://v1/nsplsh_e24d88fb732446e48d71951b09c571e8~mv2.jpg/a%20man%20with%20a%20lot%20of%20tattoos%20on%20his%20chest.jpg#originWidth=3818&originHeight=4772"
87 * }
88 * },
89 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
90 * "minutesToRead": 1,
91 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
92 * "pricingPlanIds": [],
93 * "relatedPostIds": [],
94 * "seoData": {
95 * "settings": {
96 * "keywords": [],
97 * "preventAutoRedirect": false
98 * },
99 * "tags": []
100 * },
101 * "slugs": [],
102 * "status": "DELETED",
103 * "tagIds": [],
104 * "title": "When we stand together",
105 * "translations": []
106 * },
107 * {
108 * "_id": "66935097-31c5-4fab-9693-aa1b53aeea77",
109 * "_createdDate": "2024-01-07T08:39:26.900Z",
110 * "categoryIds": [],
111 * "changeOrigin": "MOVE_TO_TRASH",
112 * "commentingEnabled": true,
113 * "contentId": "659a6364bb866d6c2d674b4d",
114 * "coverMedia": {
115 * "custom": false,
116 * "displayed": true,
117 * "enabled": true,
118 * "image": "wix:image://v1/11062b_9874b9821b9a4c92a07b1349883fbc42~mv2_d_3000_4507_s_4_2.jpg#originWidth=3000&originHeight=4507"
119 * },
120 * "editedDate": "2024-01-07T08:40:08.655Z",
121 * "editingSessionId": "1a140780-9d07-4d18-b914-a6d69c313879",
122 * "featured": false,
123 * "hashtags": [],
124 * "hasUnpublishedChanges": true,
125 * "language": "en",
126 * "media": {
127 * "custom": false,
128 * "displayed": true,
129 * "wixMedia": {
130 * "image": "wix:image://v1/11062b_9874b9821b9a4c92a07b1349883fbc42~mv2_d_3000_4507_s_4_2.jpg#originWidth=3000&originHeight=4507"
131 * }
132 * },
133 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
134 * "minutesToRead": 1,
135 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
136 * "pricingPlanIds": [],
137 * "relatedPostIds": [],
138 * "seoData": {
139 * "tags": []
140 * },
141 * "slugs": [],
142 * "status": "DELETED",
143 * "tagIds": [],
144 * "title": "This is a draft",
145 * "translations": []
146 * }
147 * ],
148 * "metaData": {
149 * "count": 3,
150 * "offset": 0,
151 * "total": 3
152 * }
153 * }
154 */