from typing import Optional, List
import uuid

from sqlalchemy import Column, String, DateTime
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.sql import func
import uuid

from config.database.connections import Base

class {{ pascal_case }}Model(Base):
    __tablename__ = "{{ name_plural }}"

    # id es de tipo uuid
    id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, index=True)
    example = Column(String, unique=True, index=True, nullable=False)
    created_at = Column(DateTime, server_default=func.now(), nullable=False)
    updated_at = Column(DateTime(timezone=True), default=func.now(), onupdate=func.now(), nullable=False)
    deleted_at = Column(DateTime, nullable=True)

    def to_dict(self, include: Optional[List[str]] = None) -> dict:
        data = {
            "id": str(self.id),
            "example": self.example,
            "deleted_at": self.deleted_at.strftime("%Y-%m-%dT%H:%M:%S.%fZ") if self.deleted_at else None
        }

        if include:
            return {k: v for k, v in data.items() if k in include}
        return data