Delete a Genre

Learn how to implement a controller that deletes the existing data from the database.

Setting up the controller

When a genre is no longer necessary, we might stop posting movies that fit into that category. A delete feature would be useful in these circumstances. We start by making the basic delete controller to accomplish this task. The genre_id of the genre that needs to be changed or accessed is needed for this controller, just like it is for the read and edit ones. Additionally, we pass this genre_id as a query parameter. Once the genre_id has been validated, we use the Mongo delete procedure to find the genre_id and delete it from the database. It’s that easy!

If the genre_id doesn’t match, an error is raised, and the request is not processed.

Get hands-on with 1200+ tech skills courses.