delete Method - Service Factory Reference

This method of a module's service deletes one or more records.

The method's name is deleteDataModel, where DataModel is the plural pascal-case name of the data model.

Delete One Record#

Code
await postModuleService.deletePosts("123")

To delete one record, pass its ID as a parameter to the method.


Delete Multiple Records#

Code
1await postModuleService.deletePosts([2  "123",3  "321",4])

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


Delete Records Matching Filters#

Code
1await postModuleService.deletePosts({2  name: "My Post",3})

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

Note: Refer to the Filtering reference for more information on accepted filters and examples.
Was this page helpful?
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