www/apps/resources/app/service-factory-reference/methods/soft-delete/page.mdx
export const metadata = {
title: softDelete Method - Service Factory Reference,
}
This method of a module's service soft deletes one or more records of a data model.
The method's name is of the format softDeleteDataModel, where DataModel is the plural pascal-case name of the data model.
const deletedPosts = await postModuleService.softDeletePosts(
"123"
)
To soft delete a record, pass its ID as a parameter to the method.
The method returns an object, whose keys are of the format {camel_case_data_model_name}_id, and their values are arrays of soft-deleted records' IDs.
For example, the returned object of the above example is:
{
"post_id": ["123"]
}
const deletedPosts = await postModuleService.softDeletePosts([
"123",
"321",
])
To soft delete multiple records, pass an array of IDs as a parameter to the method.
The method returns an object, whose keys are of the format {camel_case_data_model_name}_id, and their values are arrays of soft-deleted records' IDs.
For example, the returned object of the above example is:
{
"post_id": [
"123",
"321"
]
}
const deletedPosts = await postModuleService.softDeletePosts({
name: "My Post",
})
To soft 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.
</Note>The method returns an object, whose keys are of the format {camel_case_data_model_name}_id, and their values are arrays of soft-deleted records' IDs.
For example, the returned object of the above example is:
{
"post_id": ["123"]
}