2025-06-05 14:29:01 +00:00

50 lines
895 B
Python

from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel
# Shared properties
class TagBase(BaseModel):
name: Optional[str] = None
color: Optional[str] = "#FFFFFF"
# Properties to receive via API on creation
class TagCreate(TagBase):
name: str
# Properties to receive via API on update
class TagUpdate(TagBase):
pass
class TagInDBBase(TagBase):
id: str
created_at: datetime
class Config:
from_attributes = True
# Additional properties to return via API
class Tag(TagInDBBase):
pass
# For response models that need to include notes
class TagWithNotes(Tag):
notes: List["NoteBasic"] = []
# Simple Note schema for use in TagWithNotes to avoid circular imports
class NoteBasic(BaseModel):
id: str
title: str
class Config:
from_attributes = True
TagWithNotes.update_forward_refs()