18 lines
473 B
Python
18 lines
473 B
Python
"""SQLAlchemy base model."""
|
|
|
|
from datetime import datetime
|
|
from sqlalchemy import func
|
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
"""Base class for all models."""
|
|
pass
|
|
|
|
|
|
class TimestampMixin:
|
|
"""Mixin for created_at and updated_at timestamps."""
|
|
|
|
created_at: Mapped[datetime] = mapped_column(default=func.now())
|
|
updated_at: Mapped[datetime] = mapped_column(default=func.now(), onupdate=func.now())
|