How to fetch documents from a mongodb cursor

Hello
How can I retrieve Documents from a mongodb cursor - got stuck here
nestbox/breed.rs at dev · sdoerig/nestbox · GitHub line 36.
I'm using mongodb with actix-web 3.0. Maybe somebody has a hint for me.
Many thanks
Stefan

The mongodb Cursor doc has an example that looks like it does what you want:

let results: Vec<Result<Document>> = cursor.collect().await;

Note that it's a Vec<Result<Document>> rather than a Vec<Document> because the retrieval is fallible; you'll need to decide how to handle that in your app.

Hello @abe_egnor

Thanks a lot - I saw the example you mentioned - but I did not get it. Anyway you pointed me to the right direction - the following code compiles

use futures::StreamExt;
use mongodb::error::Error;
let results: Vec<Result<Document, Error>> = cursor.collect().await;

Have a nice time

Stefan