This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from src.db.models.bookshelf import Book
|
||||
from src.db.session import SessionDep
|
||||
from src.schema.bookshelf.book import BookResponse, to_response
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/books", response_model=List[BookResponse])
|
||||
def get_all_artists(db: SessionDep) -> List[BookResponse]:
|
||||
results: List[BookResponse] = []
|
||||
books = db.query(Book).all()
|
||||
for book in books:
|
||||
response = to_response(book)
|
||||
results.append(response)
|
||||
return results
|
||||
Reference in New Issue
Block a user