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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user