[UPD] Added api to create Library

This commit is contained in:
2026-02-15 10:36:37 +01:00
parent bb8324ad1d
commit c468f51672
17 changed files with 142 additions and 9 deletions

View File

@@ -10,8 +10,8 @@ from .base import Base
class Library(Base):
__tablename__ = "library"
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(String(255))
notes: Mapped[str] = mapped_column(String(65656))
name: Mapped[str] = mapped_column(String(255), unique=True)
notes: Mapped[Optional[str]] = mapped_column(String(65656))
envs: Mapped[List["Env"]] = relationship(
back_populates="library", cascade="all, delete-orphan"
@@ -29,5 +29,12 @@ class Library(Base):
back_populates="library", cascade="all, delete-orphan"
)
def to_dict(self) -> dict:
return {
"id": self.id,
"name": self.name,
"notes": self.notes
}
def __repr__(self) -> str:
return f"Library(id={self.id!r}, name={self.name!r}, notes={self.notes!r})"