-
-
Notifications
You must be signed in to change notification settings - Fork 105
Database
Mr.Miss edited this page Feb 22, 2021
·
5 revisions
Anjani uses MongoDB with Motor an asynchronous Python driver for MongoDB.
~Anjani.get_collection()
Get collection from the database.
Parameters:
-
name (
str
) - Collection name to fetch.
from anjani_bot import listener, plugin
class TestDB(plugin.Plugin):
name = "test-db"
# It's recomended to load DataBase on __on_load__
# this method executed when the plugin is loaded
async def __on_load__(self):
self.db_collection = self.bot.get_collection("<COLLECTION_NAME>")
async def get_data(self, value) -> dict:
data = await self.db_collection.find_one({'some_key': value})
return data
Wiki of Anjani © Copyright 2021, UserBotIndo