Hi everyone.
Let's go to the final operation will be DELETE and in this video I will create a delete.
I will create a service first and async deleteOne, take the id
And in here, I use the syntax.
await
this.
postModel.deleteOne
Okay, I will delete and pass it the condition will be the _id: id right here
Okay.
And I can use the post right here.
Why? I can use the post right here, because I need to check it exist or not
Right.
Because if it's not exist
It will throw the error in this case.
So for that reason, I can use something like this.
Okay.
That's it, I don't need to return anything because this is the DELETE operation.
And in here in the controller I will create a delete.
id
And this one.
Sorry.
deleteOne
Right.
And id: string, I'll return
this.postService.
.deleteOne()
And that
is the delete.
Okay.
That's it
And let me go to here and I will let me change the update post.
And let me.
Duplicate and change.
DELETE and delete
post and I will use the ID right here.
If I use difference id.
I send, this say.
post with id right here not found
If I use the correct id
I send, okay, it's already removed and it doesn't show anything because I don't return anything.
And if check the data, right.
Now you can see, this already removed the first one of the post, right.
So that's it for the video.
I will see you in the next one.