Created genre table and added links and endpoints for it.

This commit is contained in:
2025-06-25 14:50:28 +03:00
parent 83dbb1824e
commit 9604771439
9 changed files with 158 additions and 19 deletions

View File

@@ -1,14 +1,17 @@
from .author import Author
from .book import Book
from .genre import Genre
from .links import (
AuthorBookLink, GenreBookLink,
AuthorWithBooks, BookWithAuthors,
GenreWithBooks, BookWithAuthorsAndGenres
GenreWithBooks, BookWithGenres,
BookWithAuthorsAndGenres
)
__all__ = [
'Author', 'Book',
'Author', 'Book', 'Genre',
'AuthorBookLink', 'AuthorWithBooks',
'BookWithAuthors', 'GenreBookLink',
'GenreWithBooks', 'BookWithAuthorsAndGenres'
'GenreWithBooks', 'BookWithGenres',
'BookWithAuthorsAndGenres'
]

View File

@@ -9,6 +9,6 @@ if TYPE_CHECKING:
class Genre(GenreBase, table=True):
id: Optional[int] = Field(default=None, primary_key=True, index=True)
books: List["Book"] = Relationship(
back_populates="authors",
back_populates="genres",
link_model=GenreBookLink
)