+ api
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user