@@ -19,7 +19,9 @@ async def retrieve_document(document_id: str, collection: str) -> dict:
1919 :return:
2020 """
2121 document_filter = {"_id" : ObjectId (document_id )}
22- if document := await greens .app .state .mongo_collection [collection ].find_one (document_filter ):
22+ if document := await greens .app .state .mongo_collection [collection ].find_one (
23+ document_filter
24+ ):
2325 return await document_id_helper (document )
2426 else :
2527 raise ValueError (f"No document found for { document_id = } in { collection = } " )
@@ -33,8 +35,9 @@ async def create_document(document, collection: str) -> InsertOneResult:
3335 :return:
3436 """
3537 try :
36- document : InsertOneResult = await greens .app .state .mongo_collection [collection ].insert_one (
37- document .model_dump ())
38+ document : InsertOneResult = await greens .app .state .mongo_collection [
39+ collection
40+ ].insert_one (document .model_dump ())
3841 return document
3942 except WriteError as e :
4043 # TODO: this not make sense as id from mongo will be always unique if we not pass it
@@ -45,6 +48,12 @@ async def get_mongo_meta() -> dict:
4548 list_databases = await greens .app .state .mongo_client .list_database_names ()
4649 list_of_collections = {}
4750 for db in list_databases :
48- list_of_collections [db ] = await greens .app .state .mongo_client [db ].list_collection_names ()
51+ list_of_collections [db ] = await greens .app .state .mongo_client [
52+ db
53+ ].list_collection_names ()
4954 mongo_meta = await greens .app .state .mongo_client .server_info ()
50- return {"version" : mongo_meta ["version" ], "databases" : list_databases , "collections" : list_of_collections }
55+ return {
56+ "version" : mongo_meta ["version" ],
57+ "databases" : list_databases ,
58+ "collections" : list_of_collections ,
59+ }
0 commit comments