fooder-api/fooder/domain/base.py

24 lines
547 B
Python
Raw Normal View History

2023-04-01 16:19:12 +02:00
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, declared_attr
from sqlalchemy import Integer
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
"""
return cls.__name__.lower()
id: Mapped[int] = mapped_column(primary_key=True)