44 lines
808 B
Python
44 lines
808 B
Python
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class SongBase(BaseModel):
|
|
title: Optional[str] = None
|
|
duration: Optional[float] = None
|
|
file_path: Optional[str] = None
|
|
track_number: Optional[int] = None
|
|
artist_id: Optional[int] = None
|
|
album_id: Optional[int] = None
|
|
|
|
|
|
# Properties to receive on song creation
|
|
class SongCreate(SongBase):
|
|
title: str
|
|
file_path: str
|
|
artist_id: int
|
|
|
|
|
|
# Properties to receive on song update
|
|
class SongUpdate(SongBase):
|
|
pass
|
|
|
|
|
|
class SongInDBBase(SongBase):
|
|
id: int
|
|
title: str
|
|
file_path: str
|
|
artist_id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Song(SongInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties stored in DB
|
|
class SongInDB(SongInDBBase):
|
|
pass |