|
1
|
--- |
|
2
|
sidebar_label: "delete" |
|
3
|
--- |
|
4
|
|
|
5
|
export const metadata = { |
|
6
|
title: `delete Method - Service Factory Reference`, |
|
7
|
} |
|
8
|
|
|
9
|
# {metadata.title} |
|
10
|
|
|
11
|
This method of a module's service deletes one or more records. |
|
12
|
|
|
13
|
The method's name is `deleteDataModel`, where `DataModel` is the plural pascal-case name of the data model. |
|
14
|
|
|
15
|
## Delete One Record |
|
16
|
|
|
17
|
```ts |
|
18
|
await postModuleService.deletePosts("123") |
|
19
|
``` |
|
20
|
|
|
21
|
To delete one record, pass its ID as a parameter to the method. |
|
22
|
|
|
23
|
--- |
|
24
|
|
|
25
|
## Delete Multiple Records |
|
26
|
|
|
27
|
```ts |
|
28
|
await postModuleService.deletePosts([ |
|
29
|
"123", |
|
30
|
"321", |
|
31
|
]) |
|
32
|
``` |
|
33
|
|
|
34
|
To delete multiple records, pass an array of IDs as a parameter to the method. |
|
35
|
|
|
36
|
--- |
|
37
|
|
|
38
|
## Delete Records Matching Filters |
|
39
|
|
|
40
|
```ts |
|
41
|
await postModuleService.deletePosts({ |
|
42
|
name: "My Post", |
|
43
|
}) |
|
44
|
``` |
|
45
|
|
|
46
|
To delete records matching a set of filters, pass an object of filters as a parameter to the method. |
|
47
|
|
|
48
|
<Note> |
|
49
|
|
|
50
|
Refer to the [Filtering](../../tips/filtering/page.mdx) reference for more information on accepted filters and examples. |
|
51
|
|
|
52
|
</Note> |