fooder-api/fooder/domain/base.py

23 lines
532 B
Python
Raw Normal View History

2023-04-01 16:19:12 +02:00
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, declared_attr
class Base(DeclarativeBase):
"""Base from DeclarativeBase"""
pass
class CommonMixin:
"""define a series of common elements that may be applied to mapped
classes using this class as a mixin class."""
@declared_attr.directive
def __tablename__(cls) -> str:
"""__tablename__.
:rtype: str
"""
2024-05-20 13:45:21 +02:00
return cls.__name__.lower() # type: ignore
2023-04-01 16:19:12 +02:00
id: Mapped[int] = mapped_column(primary_key=True)