mirror of
https://github.com/kurbezz/discord-bot.git
synced 2025-12-06 07:05:36 +01:00
19 lines
402 B
Python
19 lines
402 B
Python
import abc
|
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
from core.mongo import mongo_manager
|
|
|
|
|
|
class BaseRepository(abc.ABC):
|
|
COLLECTION_NAME: str
|
|
|
|
@classmethod
|
|
@asynccontextmanager
|
|
async def connect(cls):
|
|
async with mongo_manager.connect() as client:
|
|
db = client.get_default_database()
|
|
collection = db[cls.COLLECTION_NAME]
|
|
|
|
yield collection
|