25 lines
734 B
Python
25 lines
734 B
Python
import pymongo
|
|
from bson import ObjectId
|
|
from motor.motor_asyncio import AsyncIOMotorDatabase
|
|
|
|
import schemas
|
|
from crud.base import CRUDBase
|
|
from schemas import *
|
|
|
|
__all__ = 'event_mana',
|
|
|
|
|
|
class CRUDEventMap(CRUDBase):
|
|
|
|
async def edit_event_mate(self, db: AsyncIOMotorDatabase, game: str, data_id: schemas.EventMateEdit):
|
|
await self.update_one(db, {'game': game, 'event_name': data_id.show_name}, {'$set': data_id.dict()},
|
|
upsert=True)
|
|
|
|
async def create_index(self, db: AsyncIOMotorDatabase):
|
|
await db[self.coll_name].create_index(
|
|
[('game', pymongo.DESCENDING), ('event_name', pymongo.DESCENDING)],
|
|
unique=True)
|
|
|
|
|
|
event_mana = CRUDEventMap('event_mana')
|