This commit is contained in:
xds
2026-02-03 16:21:15 +03:00
parent cba813337e
commit e43cd575b0
3 changed files with 12 additions and 6 deletions

View File

@@ -15,8 +15,11 @@ class CharacterRepo:
character.id = op.inserted_id
return character
async def get_character(self, character_id: str) -> Character | None:
res = await self.collection.find_one({"_id": ObjectId(character_id)})
async def get_character(self, character_id: str, with_image_data: bool = False) -> Character | None:
args = {}
if not with_image_data:
args["character_image_data"] = 0
res = await self.collection.find_one({"_id": ObjectId(character_id)}, args)
if res is None:
return None
else:
@@ -24,7 +27,7 @@ class CharacterRepo:
return Character(**res)
async def get_all_characters(self) -> List[Character]:
docs = await self.collection.find().to_list(None)
docs = await self.collection.find({}, {"character_image_data": 0}).to_list(None)
characters = []
for doc in docs:
@@ -38,4 +41,3 @@ class CharacterRepo:
async def update_char(self, char_id: str, character: Character) -> None:
await self.collection.update_one({"_id": ObjectId(char_id)}, {"$set": character.model_dump()})