ThalamOS
a powerful Flask web application designed to enhance your storage management.
Loading...
Searching...
No Matches
models.py
Go to the documentation of this file.
1"""
2Models Module
3
4This module defines the database models using SQLModel and Pydantic.
5It includes the StorageItem model and the StorageItemType enumeration.
6"""
7from datetime import datetime
8from enum import Enum
9from typing import Optional
10from sqlmodel import Field, SQLModel
11
12
13class StorageItemType(str, Enum):
14 """Enumeration for different types of storage items."""
15 SENSOR = "SENSOR"
16 SCREW = "SCREW"
17 DISPLAY = "DISPLAY"
18 NAIL = "NAIL"
19 CABLE = "CABLE"
20 MISCELLANEOUS = "MISCELLANEOUS"
21
22
23class StorageItem(SQLModel, table=True):
24 """Data model representing an item in the storage database."""
25 __tablename__ = "storage"
26 id: Optional[int] = Field(default=None, primary_key=True)
27 position: int
28 type: StorageItemType
29 name: str
30 info: Optional[str] = None
31 modification_time: datetime = Field(default_factory=datetime.now)