mirror of
https://github.com/wowlikon/LibraryAPI.git
synced 2025-12-11 21:30:46 +00:00
Created models for genres
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user