LogicGoInfotechSpaces commited on
Commit
8a81353
·
verified ·
1 Parent(s): efdef95

Update app/db/mongo.py

Browse files
Files changed (1) hide show
  1. app/db/mongo.py +2 -42
app/db/mongo.py CHANGED
@@ -46,46 +46,6 @@ def get_autocategory_collection() -> AsyncIOMotorCollection:
46
  def get_api_logs_collection() -> AsyncIOMotorCollection:
47
  return get_database()[settings.api_logs_collection]
48
 
49
- # from __future__ import annotations
50
 
51
- # from typing import Optional
52
-
53
- # from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorCollection, AsyncIOMotorDatabase
54
-
55
- # from app.core.config import settings
56
-
57
- # _mongo_client: Optional[AsyncIOMotorClient] = None
58
-
59
-
60
- # async def connect_to_mongo() -> None:
61
- # """Initialize the MongoDB client once during application startup."""
62
- # global _mongo_client
63
- # if _mongo_client is not None:
64
- # return
65
-
66
- # client = AsyncIOMotorClient(settings.mongo_uri, serverSelectionTimeoutMS=5000)
67
- # # Trigger a server selection to fail fast if the URI/config is invalid.
68
- # await client.server_info()
69
- # _mongo_client = client
70
-
71
-
72
- # async def close_mongo_connection() -> None:
73
- # global _mongo_client
74
- # if _mongo_client is None:
75
- # return
76
- # _mongo_client.close()
77
- # _mongo_client = None
78
-
79
-
80
- # def get_client() -> AsyncIOMotorClient:
81
- # if _mongo_client is None:
82
- # raise RuntimeError("MongoDB client is not initialized. Wait for startup to finish.")
83
- # return _mongo_client
84
-
85
-
86
- # def get_database() -> AsyncIOMotorDatabase:
87
- # return get_client()[settings.mongo_db]
88
-
89
-
90
- # def get_autocategory_collection() -> AsyncIOMotorCollection:
91
- # return get_database()[settings.mongo_collection]
 
46
  def get_api_logs_collection() -> AsyncIOMotorCollection:
47
  return get_database()[settings.api_logs_collection]
48
 
 
49
 
50
+ def get_subcategory_collection() -> AsyncIOMotorCollection:
51
+ return get_database()[settings.mongo_subcategory_collection]