mirror of
https://github.com/ANewProfile/breadcrumbs.git
synced 2026-09-23 07:19:56 +02:00
25 lines
566 B
Python
25 lines
566 B
Python
# backend/database.py
|
|
from pymongo import MongoClient
|
|
from dotenv import load_dotenv
|
|
import certifi
|
|
import os
|
|
|
|
load_dotenv()
|
|
|
|
_uri = os.getenv("MONGODB_URI", "mongodb://localhost:27017")
|
|
_use_tls = _uri.startswith("mongodb+srv://")
|
|
|
|
client = MongoClient(
|
|
_uri,
|
|
tls=_use_tls,
|
|
tlsCAFile=certifi.where() if _use_tls else None,
|
|
)
|
|
db = client["breadcrumbs"]
|
|
|
|
# create collections
|
|
tasks_collection = db["tasks"]
|
|
settings_collection = db["settings"]
|
|
users_collection = db["users"]
|
|
sessions_collection = db["sessions"]
|
|
no_go_zones_collection = db["no_go_zones"]
|