48 lines
923 B
Python
48 lines
923 B
Python
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from app.schemas.song import Song
|
|
|
|
|
|
# Shared properties
|
|
class PlaylistBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
is_public: bool = True
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class PlaylistCreate(PlaylistBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class PlaylistUpdate(PlaylistBase):
|
|
name: Optional[str] = None
|
|
|
|
|
|
class PlaylistInDBBase(PlaylistBase):
|
|
id: str
|
|
user_id: str
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class Playlist(PlaylistInDBBase):
|
|
pass
|
|
|
|
|
|
# Additional properties stored in DB
|
|
class PlaylistInDB(PlaylistInDBBase):
|
|
pass
|
|
|
|
|
|
# For returning playlist with songs
|
|
class PlaylistWithSongs(Playlist):
|
|
songs: List[Song] = [] |