fix: make close() sync (motor close is sync); guard doc[key] on missing fields

close() was async but only called motor's synchronous client.close(), misleading callers into awaiting it; it is now a plain def and the docstring + README examples drop the await. get_document_hashmap/get_document_fields indexed doc[key] unguarded, so a doc missing the field raised KeyError that the broad except swallowed, conflating 'no documents' with 'field absent'; both now skip docs lacking the key.

Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
2026-06-28 17:46:20 -04:00
parent 6a9de93691
commit eabfe0cbc3
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ from mongo import Mongo
db = Mongo(conn_string, database) # attach as bot.db / app.db
users = await db.get_documents("users", {"active": True})
await db.close() # on shutdown
db.close() # on shutdown (sync)
```
**Module proxy (back-compat)** — arm once, then call bare: