Moulding / api /dependencies.py
madhurithika22's picture
Deploy backend files to Hugging Face Spaces
868a90a
Raw
History Blame Contribute Delete
350 Bytes
from database.connection import db_client
from core.config import settings
async def get_db():
"""Dependency to yield the active MongoDB instance or None if offline."""
if not db_client.client:
return None
try:
# Return DB handle
return db_client.client[settings.DB_NAME]
except Exception:
return None