Download app/db/mongodb.py from Hammad712/Video-Rag: direct link, hf CLI and curl.
- Browser
- Download file 613 Bytes
-
https://huggingface.co/spaces/Hammad712/Video-Rag/resolve/main/app/db/mongodb.py
- Command line
-
hf download hf://spaces/Hammad712/Video-Rag/app/db/mongodb.py
-
curl -L -o mongodb.py https://huggingface.co/spaces/Hammad712/Video-Rag/resolve/main/app/db/mongodb.py
613 Bytes
| from pymongo import MongoClient | |
| from ..config import settings | |
| class MongoDB: | |
| def __init__(self): | |
| self.client = MongoClient(settings.CONNECTION_STRING) | |
| self.db = self.client[settings.DATABASE_NAME] | |
| self.users = self.db["users"] | |
| self.videos = self.db[settings.COLLECTION_NAME] | |
| # Indexes | |
| self.users.create_index("username", unique=True) | |
| self.users.create_index("email", unique=True) | |
| self.videos.create_index("video_id", unique=True) | |
| self.videos.create_index("user_id") | |
| def close(self): | |
| self.client.close() | |
| mongodb = MongoDB() |