Search...
restoreFromTrashBin( )
Restores a deleted draft post from the trash bin by the provided ID.
Description
Uses the draftPostId
to restore a deleted draft post from the trash bin.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function restoreFromTrashBin(draftPostId: string): Promise<RestoreFromTrashBinResponse>
restoreFromTrashBin Parameters
NAME
TYPE
DESCRIPTION
draftPostId
string
Draft post ID.
Returns
Return Type:
Promise<
RestoreFromTrashBinResponse
>NAME
TYPE
DESCRIPTION
draftPost
DraftPost
Restored draft post info.
Was this helpful?
Restore a draft post from the trash bin (export from backend code)
Copy Code
1import { draftPosts } from 'wix-blog-backend';2import { webMethod, Permissions } from 'wix-web-module';34// Sample draftPostId value: "a128796d-6df0-4dae-9d4b-f0fc3441f42d"56export const myRestoreFromTrashBinFunction = webMethod(7 Permissions.Admin,8 async (draftPostId) => {9 try {10 const restoredDraftPost = await draftPosts.restoreFromTrashBin(draftPostId);11 console.log('Successfully restored the following draft post:', restoredDraftPost);12 return restoredDraftPost;13 } catch (error) {14 console.error(error);15 // Handle the error16 }17 }18);1920/* Promise resolves to:21 * {22 * "draftPost": {23 * "_id": "a128796d-6df0-4dae-9d4b-f0fc3441f42d",24 * "_createdDate": "2024-01-09T11:43:30.710Z",25 * "categoryIds": [26 * "c8780752-f517-4cf9-9c18-0f9a22d00926",27 * "2b2ccb5a-e709-45a1-8353-bb3332b91297"28 * ],29 * "changeOrigin": "RESTORE",30 * "commentingEnabled": true,31 * "contentId": "65a6449869a6e0d73c4ae0dd",32 * "coverMedia": {33 * "custom": false,34 * "displayed": true,35 * "enabled": true,36 * "image": "wix:image://image.jpg#originWidth=3000&originHeight=2000"37 * },38 * "editedDate": "2024-01-16T08:55:52.829Z",39 * "editingSessionId": "87f1a172-1632-42ec-bccd-1c22a54ca219",40 * "featured": true,41 * "hashtags": [],42 * "hasUnpublishedChanges": true,43 * "language": "en",44 * "media": {45 * "custom": false,46 * "displayed": true,47 * "wixMedia": {48 * "image": "wix:image://image.jpg#originWidth=3000&originHeight=2000"49 * }50 * },51 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",52 * "minutesToRead": 0,53 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",54 * "pricingPlanIds": [],55 * "relatedPostIds": [],56 * "seoData": {57 * "settings": {58 * "keywords": [],59 * "preventAutoRedirect": false60 * },61 * "tags": []62 * },63 * "slugs": [],64 * "status": "UNPUBLISHED",65 * "tagIds": [66 * "27f5320b-d91f-4435-9b9b-4b1d41b2ae70",67 * "6d2e0a31-0f5e-4de8-8fd7-e45352bdfa67"68 * ],69 * "title": "Genius Ways",70 * "translations": []71 * }72 * }73 */74
Restore a draft post from the trash bin
Copy Code
1import { draftPosts } from 'wix-blog-backend';23// Sample draftPostId value: "a128796d-6df0-4dae-9d4b-f0fc3441f42d"45export async function myRestoreFromTrashBinFunction(draftPostId) {6 try {7 const restoredDraftPost = await draftPosts.restoreFromTrashBin(draftPostId);8 console.log('Successfully restored the following draft post:', restoredDraftPost);9 return restoredDraftPost;10 } catch (error) {11 console.error(error);12 // Handle the error13 }14 }1516/* Promise resolves to:17 * {18 * "draftPost": {19 * "_id": "a128796d-6df0-4dae-9d4b-f0fc3441f42d",20 * "_createdDate": "2024-01-09T11:43:30.710Z",21 * "categoryIds": [22 * "c8780752-f517-4cf9-9c18-0f9a22d00926",23 * "2b2ccb5a-e709-45a1-8353-bb3332b91297"24 * ],25 * "changeOrigin": "RESTORE",26 * "commentingEnabled": true,27 * "contentId": "65a6449869a6e0d73c4ae0dd",28 * "coverMedia": {29 * "custom": false,30 * "displayed": true,31 * "enabled": true,32 * "image": "wix:image://image.jpg#originWidth=3000&originHeight=2000"33 * },34 * "editedDate": "2024-01-16T08:55:52.829Z",35 * "editingSessionId": "87f1a172-1632-42ec-bccd-1c22a54ca219",36 * "featured": true,37 * "hashtags": [],38 * "hasUnpublishedChanges": true,39 * "language": "en",40 * "media": {41 * "custom": false,42 * "displayed": true,43 * "wixMedia": {44 * "image": "wix:image://image.jpg#originWidth=3000&originHeight=2000"45 * }46 * },47 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",48 * "minutesToRead": 0,49 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",50 * "pricingPlanIds": [],51 * "relatedPostIds": [],52 * "seoData": {53 * "settings": {54 * "keywords": [],55 * "preventAutoRedirect": false56 * },57 * "tags": []58 * },59 * "slugs": [],60 * "status": "UNPUBLISHED",61 * "tagIds": [62 * "27f5320b-d91f-4435-9b9b-4b1d41b2ae70",63 * "6d2e0a31-0f5e-4de8-8fd7-e45352bdfa67"64 * ],65 * "title": "Genius Ways",66 * "translations": []67 * }68 * }69 */70