Skip to content

Commit

Permalink
Edited some
Browse files Browse the repository at this point in the history
  • Loading branch information
SRaswan committed Dec 4, 2023
1 parent 1ed5145 commit 1a46e04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ test {

mainClassName = 'App'

// mainClassName = 'server.Server'
//mainClassName = 'server.Server'
7 changes: 4 additions & 3 deletions src/main/java/server/DeleteRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public void handle(HttpExchange exchange) throws IOException {
String recipeMealType = json.getString("mealType");
String recipeIngredients = json.getString("ingredients");
String recipeInstructions = json.getString("instructions");
updateRecipe(userID, recipeName, recipeIngredients, recipeInstructions, recipeMealType);
deleteRecipe(userID, recipeName, recipeIngredients, recipeInstructions, recipeMealType);
}
return;

}

public void updateRecipe(String id, String recipeName, String recipeIngredients, String recipeInstructions,
public void deleteRecipe(String id, String recipeName, String recipeIngredients, String recipeInstructions,
String mealType) {
String uri = "mongodb+srv://aditijain:[email protected]/?retryWrites=true&w=majority";
try (MongoClient mongoClient = MongoClients.create(uri)) {
Expand All @@ -63,10 +63,11 @@ public void updateRecipe(String id, String recipeName, String recipeIngredients,
MongoDatabase RecipeDB = mongoClient.getDatabase("recipe_db");
MongoCollection<Document> recipesCollection = RecipeDB.getCollection("recipes");

// DOESNT ACTUALLY DELETE FIND OUT HOW TO DO THIS MAYBE FILTER IS WRONG LOL
Bson filter = recipesCollection.find(and(eq("userID", id), eq("recipeName", recipeName))).first();
System.out.println(filter);
DeleteResult delteteResult = recipesCollection.deleteOne(filter);
System.out.println("Updated");
System.out.println("Deleted");
System.out.println(delteteResult);
} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit 1a46e04

Please sign in to comment.