초기 커밋
This commit is contained in:
27
app/models/mongodb/device_log.py
Normal file
27
app/models/mongodb/device_log.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from beanie import Document
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class DeviceLog(Document):
|
||||
device_id: str
|
||||
event_type: str
|
||||
payload: dict = Field(default_factory=dict)
|
||||
ip_address: str | None = None
|
||||
timestamp: datetime = Field(default_factory=datetime.utcnow)
|
||||
|
||||
class Settings:
|
||||
name = "device_logs"
|
||||
indexes = [
|
||||
"device_id",
|
||||
"event_type",
|
||||
[("timestamp", -1)],
|
||||
]
|
||||
# TTL: 90일 후 자동 삭제
|
||||
timeseries = {
|
||||
"timeField": "timestamp",
|
||||
"expireAfterSeconds": 90 * 24 * 3600,
|
||||
}
|
||||
Reference in New Issue
Block a user