Add Score route
This commit is contained in:
+17
-8
@@ -1,12 +1,21 @@
|
||||
from sqlmodel import Field, SQLModel
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class Score(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
user_id: Optional[int] = Field(default=None, foreign_key="user.id")
|
||||
movie_id: Optional[int] = Field(default=None, foreign_key="movie.id")
|
||||
score: int
|
||||
created_at: datetime = Field(default_factory=datetime.utcnow)
|
||||
updated_at: datetime = Field(default_factory=datetime.utcnow)
|
||||
class ScoreBase(BaseModel):
|
||||
user_id: str = Field(
|
||||
description="UUID representation of the user",
|
||||
examples=["123e4567-e89b-12d3-a456-426655440000"],
|
||||
)
|
||||
movie_id: str = Field(
|
||||
description="UUID representation of the movie",
|
||||
examples=["123e4567-e89b-12d3-a456-426655440000"],
|
||||
)
|
||||
score: int = Field(description="Score of the movie", examples=[5], ge=-18, le=33)
|
||||
created_at: Optional[datetime] = Field(default_factory=datetime.utcnow)
|
||||
updated_at: Optional[datetime] = Field(default_factory=datetime.utcnow)
|
||||
|
||||
|
||||
class ScoreDB(ScoreBase):
|
||||
id: Optional[str]
|
||||
|
||||
Reference in New Issue
Block a user