Skip to content

base#

SQLAlchemy Base Model

Base #

Bases: DeclarativeBase

SQLAlchemy Base Model

Source code in zoo/models/base.py
class Base(DeclarativeBase):
    """
    SQLAlchemy Base Model
    """

CreatedAtMixin #

Created Updated Mixin

Source code in zoo/models/base.py
class CreatedAtMixin:
    """
    Created Updated Mixin
    """

    created_at: Mapped[datetime.datetime] = mapped_column(
        DateTime(timezone=True), server_default=func.now()
    )

CreatedUpdatedMixin #

Bases: CreatedAtMixin, UpdatedAtMixin

Created Updated Mixin

Source code in zoo/models/base.py
class CreatedUpdatedMixin(CreatedAtMixin, UpdatedAtMixin):
    """
    Created Updated Mixin
    """

DeletedAtMixin #

Deleted At Mixin

Source code in zoo/models/base.py
class DeletedAtMixin:
    """
    Deleted At Mixin
    """

    deleted_at: Mapped[datetime.datetime] = mapped_column(
        DateTime(timezone=True), default=None, nullable=True
    )

IDMixin #

ID Mixin

Source code in zoo/models/base.py
class IDMixin:
    """
    ID Mixin
    """

    id: Mapped[int] = mapped_column(primary_key=True)  # noqa: A003

UpdatedAtMixin #

Created Updated Mixin

Source code in zoo/models/base.py
class UpdatedAtMixin:
    """
    Created Updated Mixin
    """

    updated_at: Mapped[datetime.datetime] = mapped_column(
        DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
    )