48 lines
937 B
Python
48 lines
937 B
Python
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from app.schemas.tag import Tag
|
|
|
|
|
|
# Shared properties
|
|
class NoteBase(BaseModel):
|
|
title: Optional[str] = None
|
|
content: Optional[str] = None
|
|
is_archived: Optional[bool] = False
|
|
is_pinned: Optional[bool] = False
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class NoteCreate(NoteBase):
|
|
title: str
|
|
tag_ids: Optional[List[str]] = []
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class NoteUpdate(NoteBase):
|
|
tag_ids: Optional[List[str]] = None
|
|
|
|
|
|
class NoteInDBBase(NoteBase):
|
|
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 Note(NoteInDBBase):
|
|
pass
|
|
|
|
|
|
# Nested Note model with Tags
|
|
class NoteWithTags(Note):
|
|
tags: List[Tag] = []
|
|
|
|
|
|
NoteWithTags.update_forward_refs() |