There's a following example in the docs that does not in fact work:
async def print_indexes():
for index in await db.test.list_indexes():
print(index)
The result of this is "AsyncIOMotorLatentCommandCursor can't be used in 'await' expression" error.
This example is available here: https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection.list_indexes
Correct usage is as follows:
async def print_indexes():
async for index in db.test.list_indexes():
print(index)
I have tested this and it works. It was advised to me on this forum: https://groups.google.com/forum/?fromgroups#!topic/mongodb-user/KEhu7LK2iDk
Please correct the documentation.