Skip to content

Commit

Permalink
Allow GuildData and UserData creation by _id (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
julien777z authored Feb 10, 2025
1 parent f5434b0 commit 6087446
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bloxlink_lib/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import datetime
import json
from os.path import exists
from typing import Type, TYPE_CHECKING, Any
from typing import Type, Any

from motor.motor_asyncio import AsyncIOMotorClient
from redis.asyncio import Redis
Expand Down Expand Up @@ -171,6 +171,7 @@ async def update_item(domain: str, item_id: str, **aspects) -> None:
unset_aspects = {}
set_aspects = {}

# arrange items into set and unset (delete)
for key, val in aspects.items():
if val is None:
unset_aspects[key] = ""
Expand Down
2 changes: 1 addition & 1 deletion bloxlink_lib/models/guilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __eq__(self, other):
class GuildData(BaseModel):
"""Representation of the stored settings for a guild"""

id: int
id: Annotated[int, Field(alias="_id")]
binds: Annotated[list[binds_module.GuildBind], Field(default_factory=list)]

@field_validator("binds", mode="before")
Expand Down
2 changes: 1 addition & 1 deletion bloxlink_lib/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class UserData(BaseModel):
robloxAccounts (dict): All of the user's linked accounts, and any guild specific verifications.
"""

id: int
id: Annotated[int, Field(alias="_id")]
robloxID: str | None = None
robloxAccounts: dict = Field(
default_factory=lambda: {"accounts": [], "guilds": {}, "confirms": {}}
Expand Down

0 comments on commit 6087446

Please sign in to comment.