import pymongo from bson import ObjectId from motor.motor_asyncio import AsyncIOMotorDatabase import schemas from crud.base import CRUDBase from schemas import * __all__ = 'proid_map', class CRUDProidmap(CRUDBase): # 将两个字段按对应关系组合成字典返回 async def get_all_show_name(self, db: AsyncIOMotorDatabase, game: str): cursor = self.find(db, {'game': game}) res = {} async for item in self.to_list(cursor): res[item['proid']] = item['name'] return res #将proid字段和金额money按对应关系组合成字典返回 async def get_all_show_money(self, db: AsyncIOMotorDatabase, game: str): cursor = self.find(db, {'game': game}) res = {} async for item in self.to_list(cursor): res[item['proid']] = item['money'] return res proid_map = CRUDProidmap('proid_map')