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.