-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
5 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,4 @@ test { | |
|
||
mainClassName = 'App' | ||
|
||
// mainClassName = 'server.Server' | ||
//mainClassName = 'server.Server' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) { | ||
|
@@ -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(); | ||
|