webhook_telegram_bot.database.backends.mongo

This file contains BaseDatabaseWrapper implementations for MongoDB.

Module Contents

Classes

DatabaseWrapper

This class implements BaseDatabaseWrapper for MongoDB.

Attributes

Document

webhook_telegram_bot.database.backends.mongo.Document
class webhook_telegram_bot.database.backends.mongo.DatabaseWrapper(url: str)

Bases: webhook_telegram_bot.database.backends.base.BaseDatabaseWrapper

This class implements BaseDatabaseWrapper for MongoDB.

close(self) None

Close database connection.

get_collection(self, collection_name: str) motor.motor_asyncio.AsyncIOMotorCollection

Return collection by name.

Parameters

collection_name – name of mongodb collection

Returns

instance of collection wrapper

async drop_database(self) None

Drop database.

async get_chat_by_chat_id(self, chat_id: int) webhook_telegram_bot.database.models.Chat

Return chat object by id.

Parameters

chat_id – chat identification number

Returns

Chat instance

async get_chat_by_webhook_id(self, webhook_id: str) webhook_telegram_bot.database.models.Chat

Return chat object by webhook id.

Parameters

webhook_id – webhook identification string

Returns

Chat instance

async save_chat(self, chat: webhook_telegram_bot.database.models.Chat) webhook_telegram_bot.database.models.Chat

Save chat object to database.

Parameters

chat – Chat instance

Returns

Chat instance