Skip to content

Commit

Permalink
[main] fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tapekhav committed Nov 11, 2024
1 parent fa01fb5 commit 07d72dc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/books/books.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from datetime import datetime
from flask import jsonify, request
from bson import ObjectId

class BooksService:
def __init__(self, app: any, mongo: any) -> None:
Expand Down Expand Up @@ -63,9 +64,9 @@ def update_book(request_data):
@self.__app.route("/books/<string:book>", methods=["GET"])
def get_book_by_name(book: str):
collection = self.__mongo[self.db_name][self.collection_name]
existing_book = collection.find_one({"name": book})
existing_book = collection.find_one({"_id": ObjectId(book)})
if not existing_book:
return jsonify({"error": "User does not exist"}), 404
return jsonify({"error": "Book does not exist"}), 404
existing_book["_id"] = str(existing_book["_id"])

return jsonify(existing_book), 200
Expand Down

0 comments on commit 07d72dc

Please sign in to comment.