Controllers added updated implementations and tests awaits
This commit is contained in:
17
Controllers/Mongo/implementations.py
Normal file
17
Controllers/Mongo/implementations.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Initialize the MongoDB handler with your configuration
|
||||
from Controllers.Mongo.database import mongo_handler
|
||||
|
||||
|
||||
# Use the collection with automatic retry capabilities
|
||||
with mongo_handler.collection("users") as users_collection:
|
||||
|
||||
# These operations will automatically retry on failure
|
||||
users_collection.insert_one({"username": "john", "email": "john@example.com"})
|
||||
|
||||
# Find operations also have retry capabilities
|
||||
user = users_collection.find_one({"username": "john"})
|
||||
|
||||
# Update operations will retry if they encounter transient errors
|
||||
users_collection.update_one(
|
||||
{"username": "john"}, {"$set": {"last_login": "2025-03-31"}}
|
||||
)
|
||||
Reference in New Issue
Block a user