24 lines
866 B
Python
24 lines
866 B
Python
from typing import List
|
|
from typing import Optional
|
|
from sqlalchemy import String
|
|
from sqlalchemy.orm import Mapped
|
|
from sqlalchemy.orm import mapped_column
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from .base import Base
|
|
|
|
class Book(Base):
|
|
__tablename__ = "book"
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(255))
|
|
publisher: Mapped[str] = mapped_column(String(255))
|
|
notes: Mapped[str] = mapped_column(String(65656))
|
|
classification: Mapped[int] = mapped_column(primary_key=True)
|
|
|
|
tags: Mapped[List["Tags"]] = relationship(
|
|
back_populates="books", cascade="all, delete-orphan"
|
|
)
|
|
|
|
def __repr__(self) -> str:
|
|
return f"Book(id={self.id!r}, name={self.name!r}, publisher={self.publisher!r}," \
|
|
" notes={self.notes!r}, classification={self.classification!r})" |