2024-02-04 01:55:51 +02:00
|
|
|
"""Module that provides all database collections"""
|
|
|
|
|
|
|
|
from typing import Any, Mapping
|
|
|
|
|
|
|
|
from async_pymongo import AsyncClient, AsyncCollection, AsyncDatabase
|
|
|
|
from libbot.sync import config_get
|
|
|
|
|
|
|
|
db_config: Mapping[str, Any] = config_get("database")
|
|
|
|
|
|
|
|
if db_config["user"] is not None and db_config["password"] is not None:
|
|
|
|
con_string = "mongodb://{0}:{1}@{2}:{3}/{4}".format(
|
|
|
|
db_config["user"],
|
|
|
|
db_config["password"],
|
|
|
|
db_config["host"],
|
|
|
|
db_config["port"],
|
|
|
|
db_config["name"],
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
con_string = "mongodb://{0}:{1}/{2}".format(
|
|
|
|
db_config["host"], db_config["port"], db_config["name"]
|
|
|
|
)
|
|
|
|
|
|
|
|
db_client = AsyncClient(con_string)
|
|
|
|
db: AsyncDatabase = db_client.get_database(name=db_config["name"])
|
|
|
|
|
|
|
|
col_users: AsyncCollection = db.get_collection("users")
|
2024-02-20 00:08:41 +02:00
|
|
|
col_messages: AsyncCollection = db.get_collection("messages")
|
2024-02-04 01:55:51 +02:00
|
|
|
col_warnings: AsyncCollection = db.get_collection("warnings")
|
|
|
|
col_checkouts: AsyncCollection = db.get_collection("checkouts")
|
|
|
|
col_trackings: AsyncCollection = db.get_collection("trackings")
|
|
|
|
col_authorized: AsyncCollection = db.get_collection("authorized")
|
|
|
|
col_transactions: AsyncCollection = db.get_collection("transactions")
|