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