This commit is contained in:
xds
2026-02-02 16:15:17 +03:00
commit e6aad48e72
21 changed files with 631 additions and 0 deletions

16
repos/char_repo.py Normal file
View File

@@ -0,0 +1,16 @@
from motor.motor_asyncio import AsyncIOMotorClient
from models.Character import Character
class CharacterRepo:
def __init__(self, client: AsyncIOMotorClient, db_name="bot_db"):
self.collection = client[db_name]["characters"]
async def add_character(self, character: Character) -> Character:
op = await self.collection.insert_one(character.model_dump())
character.id = op.inserted_id
return character
async def get_character(self, character_id: int) -> Character:
return await self.collection.find_one({"id": character_id})