Created models for genres

This commit is contained in:
2025-06-24 21:47:07 +03:00
parent 5db6416d79
commit 83dbb1824e
7 changed files with 76 additions and 10 deletions

View File

@@ -1,10 +1,11 @@
from typing import List, Optional, TYPE_CHECKING
from sqlmodel import SQLModel, Field, Relationship
from ..dto.book import BookBase
from .links import AuthorBookLink
from .links import AuthorBookLink, GenreBookLink
if TYPE_CHECKING:
from .author import Author
from .genre import Genre
class Book(BookBase, table=True):
id: Optional[int] = Field(default=None, primary_key=True, index=True)
@@ -12,3 +13,7 @@ class Book(BookBase, table=True):
back_populates="books",
link_model=AuthorBookLink
)
genres: List["Genre"] = Relationship(
back_populates="books",
link_model=GenreBookLink
)