32 lines
984 B
Python
32 lines
984 B
Python
from sqlmodel import SQLModel, Field
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from uuid import UUID, uuid4
|
|
|
|
class Favorite(SQLModel, table=True):
|
|
__tablename__ = "favorites"
|
|
|
|
id: Optional[UUID] = Field(default_factory=uuid4, primary_key=True)
|
|
user_id: UUID = Field(foreign_key="users.id", index=True)
|
|
|
|
# Type of favorite: 'coupon', 'business', 'taxi', 'route'
|
|
item_type: str = Field(index=True)
|
|
item_id: str = Field(index=True)
|
|
|
|
# Optional metadata
|
|
item_name: Optional[str] = None
|
|
item_image: Optional[str] = None
|
|
|
|
created_at: datetime = Field(default_factory=datetime.utcnow)
|
|
|
|
class Config:
|
|
json_schema_extra = {
|
|
"example": {
|
|
"user_id": "user-123",
|
|
"item_type": "coupon",
|
|
"item_id": "coupon-456",
|
|
"item_name": "50% descuento en restaurante",
|
|
"item_image": "/uploads/coupon.jpg"
|
|
}
|
|
}
|