Files
lkeep/src/lkeep/database/models/links.py
prodream be4e939f39
Some checks failed
Lint project / lint (push) Has been cancelled
FastAPI 11. Хранение и сокращение ссылок
2025-09-25 12:00:27 +04:00

32 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Проект: Lkeep
Автор: Иван Ашихмин
Год: 2025
Специально для проекта "Код на салфетке"
https://pressanybutton.ru/category/servis-na-fastapi/
"""
from sqlalchemy import UUID, ForeignKey, String
from sqlalchemy.orm import Mapped, mapped_column
from lkeep.database.mixins.id_mixins import IDMixin
from lkeep.database.mixins.timestamp_mixins import CreatedAtMixin
from lkeep.database.models import Base
class Link(IDMixin, CreatedAtMixin, Base):
"""
Модель сокращенной ссылки с указанием владельца.
:ivar full_link: Полная ссылка
:type full_link: str
:ivar short_link: Сокращённая ссылка
:type short_link: str
:ivar owner_id: Создатель ссылки
:type owner_id: UUID
"""
full_link: Mapped[str] = mapped_column(String)
short_link: Mapped[str] = mapped_column(String(12), unique=True, index=True)
owner_id: Mapped[UUID] = mapped_column(ForeignKey("user.id", ondelete="CASCADE"))