Store datetimes as strings

This commit is contained in:
Peter Vacho 2024-11-28 00:48:58 +01:00
parent 6f03d37ee9
commit 6f80ea686e
Signed by: school
GPG key ID: 8CFC3837052871B4
6 changed files with 8 additions and 2 deletions

View file

@ -19,3 +19,4 @@ class Category(Document):
@final
class Settings:
name: ClassVar = "category"
bson_encoders: ClassVar = {datetime: str}

View file

@ -27,3 +27,4 @@ class Event(Document):
@final
class Settings:
name: ClassVar = "events"
bson_encoders: ClassVar = {datetime: str, time: str, date: str}

View file

@ -21,3 +21,4 @@ class Invitation(Document):
@final
class Settings:
name: ClassVar = "invitations"
bson_encoders: ClassVar = {datetime: str}

View file

@ -22,3 +22,4 @@ class Notification(Document):
@final
class Settings:
name: ClassVar = "notifications"
bson_encoders: ClassVar = {datetime: str}

View file

@ -22,6 +22,7 @@ class Token(Document):
@final
class Settings:
name = "tokens"
bson_encoders: ClassVar = {datetime: str}
indexes: ClassVar = [
# Compound index for finding all tokens of given type from a specific user
[

View file

@ -1,5 +1,5 @@
from datetime import UTC, datetime
from typing import Annotated, final
from typing import Annotated, ClassVar, final
from beanie import Document, Indexed
from pydantic import EmailStr, Field
@ -16,4 +16,5 @@ class User(Document):
@final
class Settings:
name = "users"
name: ClassVar = "users"
bson_encoders: ClassVar = {datetime: str}