|
1
|
--- |
|
2
|
sidebar_label: "softDelete" |
|
3
|
--- |
|
4
|
|
|
5
|
export const metadata = { |
|
6
|
title: `softDelete Method - Service Factory Reference`, |
|
7
|
} |
|
8
|
|
|
9
|
# {metadata.title} |
|
10
|
|
|
11
|
This method of a module's service soft deletes one or more records of a data model. |
|
12
|
|
|
13
|
The method's name is of the format `softDeleteDataModel`, where `DataModel` is the plural pascal-case name of the data model. |
|
14
|
|
|
15
|
## Soft Delete One Record |
|
16
|
|
|
17
|
```ts |
|
18
|
const deletedPosts = await postModuleService.softDeletePosts( |
|
19
|
"123" |
|
20
|
) |
|
21
|
``` |
|
22
|
|
|
23
|
### Parameters |
|
24
|
|
|
25
|
To soft delete a record, pass its ID as a parameter to the method. |
|
26
|
|
|
27
|
### Returns |
|
28
|
|
|
29
|
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. |
|
30
|
|
|
31
|
For example, the returned object of the above example is: |
|
32
|
|
|
33
|
```json |
|
34
|
{ |
|
35
|
"post_id": ["123"] |
|
36
|
} |
|
37
|
``` |
|
38
|
|
|
39
|
--- |
|
40
|
|
|
41
|
## Soft Delete Multiple Records |
|
42
|
|
|
43
|
```ts |
|
44
|
const deletedPosts = await postModuleService.softDeletePosts([ |
|
45
|
"123", |
|
46
|
"321", |
|
47
|
]) |
|
48
|
``` |
|
49
|
|
|
50
|
### Parameters |
|
51
|
|
|
52
|
To soft delete multiple records, pass an array of IDs as a parameter to the method. |
|
53
|
|
|
54
|
### Returns |
|
55
|
|
|
56
|
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. |
|
57
|
|
|
58
|
For example, the returned object of the above example is: |
|
59
|
|
|
60
|
```json |
|
61
|
{ |
|
62
|
"post_id": [ |
|
63
|
"123", |
|
64
|
"321" |
|
65
|
] |
|
66
|
} |
|
67
|
``` |
|
68
|
|
|
69
|
--- |
|
70
|
|
|
71
|
## Soft Delete Records Matching Filters |
|
72
|
|
|
73
|
```ts |
|
74
|
const deletedPosts = await postModuleService.softDeletePosts({ |
|
75
|
name: "My Post", |
|
76
|
}) |
|
77
|
``` |
|
78
|
|
|
79
|
### Parameters |
|
80
|
|
|
81
|
To soft delete records matching a set of filters, pass an object of filters as a parameter to the method. |
|
82
|
|
|
83
|
<Note> |
|
84
|
|
|
85
|
Refer to the [Filtering](../../tips/filtering/page.mdx) reference for more information on accepted filters and examples. |
|
86
|
|
|
87
|
</Note> |
|
88
|
|
|
89
|
### Returns |
|
90
|
|
|
91
|
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. |
|
92
|
|
|
93
|
For example, the returned object of the above example is: |
|
94
|
|
|
95
|
```json |
|
96
|
{ |
|
97
|
"post_id": ["123"] |
|
98
|
} |
|
99
|
``` |