This commit is contained in:
xds
2026-02-03 23:16:18 +03:00
parent 43e9c263d5
commit 11c1f4f7dc
5 changed files with 80 additions and 13 deletions

View File

@@ -28,9 +28,12 @@ class AssetsRepo:
return assets
async def get_asset(self, asset_id: str, with_data: bool = True) -> Asset:
projection = {"_id": 1, "name": 1, "type": 1, "tg_doc_file_id": 1}
if with_data:
projection["data"] = 1
res = await self.collection.find_one({"_id": ObjectId(asset_id)},
{"_id": 1, "name": 1, "type": 1, "tg_doc_file_id": 1,
"data": 0 if not with_data else 1})
projection)
res["id"] = str(res.pop("_id"))
return Asset(**res)