Add GET endpoint for /library

This commit is contained in:
Backend IM Bot 2025-03-25 23:20:41 +00:00
parent 7da7b21c08
commit 23474fb3d3

View File

@ -1,5 +1,5 @@
# Entity: Book # Entity: Book, Author
```python
from fastapi import APIRouter, Depends, HTTPException, status from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from typing import List from typing import List
@ -15,4 +15,5 @@ async def get_books_by_authors(
db: Session = Depends(get_db) db: Session = Depends(get_db)
): ):
books = db.query(Book).join(Author).all() books = db.query(Book).join(Author).all()
return books return books
```