mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Mongo storage cleanup (#609)
* Update message.py Fixed syntax bug, added comma * Cleanup mongodb storage Cleaning up blank documents in DATA collection
This commit is contained in:
parent
c42b7e4b0d
commit
e70a76ff63
1 changed files with 5 additions and 3 deletions
|
|
@ -142,9 +142,11 @@ class MongoStorage(BaseStorage):
|
|||
data: Dict = None):
|
||||
chat, user = self.check_address(chat=chat, user=user)
|
||||
db = await self.get_db()
|
||||
|
||||
await db[DATA].update_one(filter={'chat': chat, 'user': user},
|
||||
update={'$set': {'data': data}}, upsert=True)
|
||||
if not data:
|
||||
await db[DATA].delete_one(filter={'chat': chat, 'user': user})
|
||||
else:
|
||||
await db[DATA].update_one(filter={'chat': chat, 'user': user},
|
||||
update={'$set': {'data': data}}, upsert=True)
|
||||
|
||||
async def get_data(self, *, chat: Union[str, int, None] = None, user: Union[str, int, None] = None,
|
||||
default: Optional[dict] = None) -> Dict:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue