restore Method - Service Factory Reference

This method restores one or more records of the data model that were soft-deleted.

Restore One Record#

Code
const restoredPosts = await postModuleService.restorePosts("123")

Parameters#

To restore one record, pass its ID as a parameter of the method.

Returns#

The method returns an object, whose keys are of the format {camel_case_data_model_name}_id, and their values are arrays of restored records' IDs.

For example, the returned object of the above example is:

Code
1restoredPosts = {2  post_id: ["123"],3}

Restore Multiple Records#

Code
1const restoredPosts = await postModuleService.restorePosts([2  "123",3  "321",4])

Parameters#

To restore multiple records, pass an array of IDs as a parameter of the method.

Returns#

The method returns an object, whose keys are of the format {camel_case_data_model_name}_id, and their values are arrays of restored records' IDs.

For example, the returned object of the above example is:

Code
1restoredPosts = {2  post_id: [3    "123",4    "321",5  ],6}

Restore Records Matching Filters#

Code
1const restoredPosts = await postModuleService.restorePosts({2  name: "My Post",3})

Parameters#

To restore records matching a set of filters, pass an object of fitlers as a parameter of the method.

NoteLearn more about accepted filters in this documentation.

Returns#

The method returns an object, whose keys are of the format {camel_case_data_model_name}_id, and their values are arrays of restored records' IDs.

For example, the returned object of the above example is:

Code
1restoredPosts = {2  post_id: [3    "123",4  ],5}
Was this page helpful?
Edit this page
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break