import typing as t

if t.TYPE_CHECKING:
    from ..core.discussions import DB_Discussion
    from ..core.users import DB_User

from datetime import datetime

from sqlmodel import SQLModel, Field, Relationship



class DB_TagUser(SQLModel, table=True):
    """
        Represents a tag-to-user relationship in the database.
    """

    __tablename__ = 'tag_user'
    user_id: t.Optional[int] = Field(default=None, primary_key=True, foreign_key='users.id')
    """The ID of the user."""
    tag_id: t.Optional[int] = Field(default=None, primary_key=True, foreign_key='tags.id')
    """The ID of the tag."""

    marked_as_read_at: t.Optional[datetime]
    """When the user marked the tag as read?"""
    is_hidden: bool = Field(default=False)
    """?"""



class DB_Tag(SQLModel, table=True):
    """
        Represents a tag in the database.
    """

    __tablename__ = 'tags'
    id: t.Optional[int] = Field(default=None, primary_key=True)
    """The ID of the tag. This is handled by the database."""

    name: str = 