42 lines
783 B
Python
42 lines
783 B
Python
from typing import Optional
|
|
from datetime import date
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class AlbumBase(BaseModel):
|
|
title: Optional[str] = None
|
|
release_date: Optional[date] = None
|
|
cover_image_path: Optional[str] = None
|
|
description: Optional[str] = None
|
|
artist_id: Optional[int] = None
|
|
|
|
|
|
# Properties to receive on album creation
|
|
class AlbumCreate(AlbumBase):
|
|
title: str
|
|
artist_id: int
|
|
|
|
|
|
# Properties to receive on album update
|
|
class AlbumUpdate(AlbumBase):
|
|
pass
|
|
|
|
|
|
class AlbumInDBBase(AlbumBase):
|
|
id: int
|
|
title: str
|
|
artist_id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Album(AlbumInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties stored in DB
|
|
class AlbumInDB(AlbumInDBBase):
|
|
pass |