mongo_util.py 616 B

123456789101112131415161718192021222324
  1. from abc import ABC
  2. from typing import Dict
  3. from motor import motor_asyncio
  4. class MongoUtil(ABC):
  5. def __init__(self):
  6. '''
  7. init mongo client
  8. '''
  9. super(MongoDB, self).__init__();
  10. self.client=motor_asyncio.AsyncIOMotorClient(connection_url)
  11. self.collection = client[""]
  12. async def update(self, record: Dict):
  13. return await self.collection.update_one(record)
  14. async def add(self, record: Dict):
  15. return await self.collection.insert_one(record)
  16. async def delete(self, record: Dict):
  17. # return await self.collection.
  18. pass