Chapter 3 – Managing Data Persistence with MongoDB
- You can delete recipes using
collection.DeleteOne()
orcollection.DeleteMany()
. Here you passbson.D({})
as the filter argument, which will match all documents in the collection.Update the
DeleteRecipeHandler
as follows:func (handler *RecipesHandler) DeleteRecipeHandler(c *gin.Context) {    id := c.Param("id")    objectId, _ := primitive.ObjectIDFromHex(id)    _, err := handler.collection.DeleteOne(handler.ctx, bson.M{        "_id": objectId,    })    if err != nil {        c.JSON(http.StatusInternalServerError,                gin.H{"error": err.Error()})        return    }    c.JSON(http.StatusOK, gin...