25 lines
552 B
Python
25 lines
552 B
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from beanie import Document
|
|
from pydantic import Field
|
|
|
|
|
|
class Notification(Document):
|
|
user_id: int
|
|
title: str
|
|
message: str
|
|
notification_type: str = "info"
|
|
is_read: bool = False
|
|
read_at: datetime | None = None
|
|
created_at: datetime = Field(default_factory=datetime.utcnow)
|
|
|
|
class Settings:
|
|
name = "notifications"
|
|
indexes = [
|
|
"user_id",
|
|
[("user_id", 1), ("is_read", 1)],
|
|
[("created_at", -1)],
|
|
]
|