Add GET endpoint for /books
This commit is contained in:
parent
63749002c6
commit
00836936d6
@ -0,0 +1,19 @@
|
||||
# Entity: Book
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
from core.database import get_db
|
||||
from core.models.book import Book
|
||||
from core.schemas.book import BookSchema
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/books", response_model=List[BookSchema], status_code=status.HTTP_200_OK)
|
||||
async def get_books(
|
||||
db: Session = Depends(get_db),
|
||||
skip: int = 0,
|
||||
limit: int = 100
|
||||
):
|
||||
books = db.query(Book).offset(skip).limit(limit).all()
|
||||
return books
|
Loading…
x
Reference in New Issue
Block a user