Add GET endpoint for /library
This commit is contained in:
parent
7da7b21c08
commit
23474fb3d3
@ -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
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user