WEBVTT

1
00:01.160 --> 00:02.720
Hi everyone.

2
00:03.170 --> 00:11.870
Let's go to the final operation will be DELETE and in this video I will create a delete.

3
00:12.050 --> 00:21.740
I will create a service first and  async deleteOne, take the id

4
00:23.630 --> 00:28.520
And in here, I use the syntax.

5
00:31.610 --> 00:31.970
await

6
00:36.830 --> 00:38.660
this.

7
00:43.580 --> 00:46.550
postModel.deleteOne

8
00:47.300 --> 00:53.450
Okay, I will delete and pass it the condition will be the _id: id right here

9
00:54.470 --> 00:54.920
Okay.

10
00:55.910 --> 01:00.470
And I can use the post right here.

11
01:01.280 --> 01:09.390
Why? I can use the post right here, because I need to check it exist or not

12
01:09.390 --> 01:09.840
Right.

13
01:09.990 --> 01:11.610
Because if it's not exist

14
01:11.640 --> 01:13.980
It will throw the error in this case.

15
01:14.010 --> 01:17.250
So for that reason, I can use something like this.

16
01:18.000 --> 01:18.300
Okay.

17
01:18.330 --> 01:22.590
That's it, I don't need to return anything because this is the DELETE operation.

18
01:23.220 --> 01:31.500
And in here in the controller I will create a delete.

19
01:34.110 --> 01:34.350
id

20
01:35.820 --> 01:37.590
And this one.

21
01:38.040 --> 01:38.460
Sorry.

22
01:38.460 --> 01:42.180
deleteOne

23
01:43.530 --> 01:43.860
Right.

24
01:44.940 --> 01:48.870
And id: string, I'll return

25
01:48.870 --> 01:50.250
this.postService.

26
01:50.250 --> 01:52.230
.deleteOne()

27
01:53.040 --> 01:53.550
And that

28
01:53.790 --> 01:55.110
is the delete.

29
01:58.110 --> 01:58.530
Okay.

30
01:58.560 --> 01:59.040
That's it

31
02:00.030 --> 02:05.940
And let me go to here and I will let me change the update post.

32
02:08.340 --> 02:09.170
And let me.

33
02:09.200 --> 02:12.950
Duplicate and change.

34
02:12.950 --> 02:15.110
DELETE and delete

35
02:16.970 --> 02:20.540
post and I will use the ID right here.

36
02:21.020 --> 02:22.490
If I use difference id.

37
02:23.450 --> 02:24.620
I send, this say.

38
02:24.650 --> 02:27.860
post with id right here not found

39
02:27.860 --> 02:29.060
If I use the correct id

40
02:29.240 --> 02:36.170
I send, okay, it's already removed and it doesn't show anything because I don't return anything.

41
02:38.210 --> 02:40.070
And if check the data, right.

42
03:01.190 --> 03:08.300
Now you can see, this already removed the first one of the post, right.

43
03:09.260 --> 03:10.730
So that's it for the video.

44
03:10.760 --> 03:12.890
I will see you in the next one.