Playing
05. Deleting an address

Episodes

0%
Your progress
  • Total: 4h 18m
  • Played: 0m
  • Remaining: 4h 18m
Join or sign in to track your progress

Transcript

00:00
OK, so you can probably already figure out how you're going to delete an address.
00:04
But let's go ahead and cover this anyway. So once again, let's create out a route here just so we can play around with this. And we'll just create this as forward slash delete. And inside of here, we'll do exactly the same thing.
00:16
Go ahead and grab the user whose address we want to delete. And then we'll go ahead and access the address relationship. And you probably guessed it. We are going to just say delete.
00:28
We don't need to pass any data down to here because that, of course, is just going to remove that from the database. So over on our homepage, we currently have an address which has been previously updated.
00:40
And of course, this exists in the database. But as we head over to the delete endpoint here that we've created, that is going to go ahead and just remove that from the database table. There's no recovering this.
00:53
It will just be completely deleted. And of course, when we head over to the homepage, there is no address. So we don't see that data anymore. So very easy to go ahead and delete a record just using the delete method.

Episode summary

In this episode, we're focusing on how to delete an address from the database. Even if it seems straightforward, we’ll still walk through the process step by step to make sure everything is clear.

We start by setting up a new route (let’s call it /delete) so we can try deleting an address in a sandboxed way. Inside this route, we grab the user whose address we want gone, access their address relationship, and use the delete method. That’s literally it—no need to pass any extra data. The delete method does all the work and immediately removes the address from the database.

To make sure it worked, we check our homepage, which previously showed an address. After hitting the delete endpoint, the address is gone—no sign of it in the UI or the database. Simple and effective! This shows just how easy it is to remove records by using the delete method.

Episode discussion

No comments, yet. Be the first!