I try to use Model::Find to complete a find_all function, but when I get the ModelCursor as result, I don't know how to iterate it. I can neither use the example code by calling next() nor use the example of Mongo official as cursor is a private member of ModelCursor.
Wither Example which is not working ( next() method not found in wither::ModelCursor<models::role::Role>)
let mut cursor = User::find(mongodb, None, None).await?;
let mut v: Vec<User> = vec![];
while let Some(user) = cursor.next().await {
v.push(user);
}
MongoDB official example which is also not working ( cursor is a private member of ModelCursor)
let cursor = coll.find(Some(doc! { "x": 1 }), None).await?;
let results: Vec<Result> = cursor.collect().await;
It will be appreciated if there is any examples, thanks.
Hello,
I try to use Model::Find to complete a find_all function, but when I get the ModelCursor as result, I don't know how to iterate it. I can neither use the example code by calling next() nor use the example of Mongo official as cursor is a private member of ModelCursor.
wither::ModelCursor<models::role::Role>
)let results: Vec<Result> = cursor.collect().await;