async fn get_champions_with_no_role(
collection: &Collection<ChampionData>,
) -> Result<Vec<ChampionData>>Expand description
⚙️ Retrieves all champions from the database without filtering by role.
This asynchronous function queries a MongoDB collection to retrieve all ChampionData documents, regardless of their role.
It is used to obtain a complete list of champions stored in the collection.
§Parameters:
collection: A reference to a MongoDB collection ofChampionDatarepresenting the champion data stored in the database.
§Returns:
Result<Vec<ChampionData>, mongodb::error::Error>: On success, returns a vector of allChampionDataobjects in the collection. On failure, returns anErrorfrom MongoDB detailing the issue.
§Example:
let champions = get_champions_with_no_role(&collection).await?;
for champion in champions {
println!("Champion: {}", champion.name);
}§⚠️ Notes:
- The function uses an empty filter (
{}) to retrieve all documents in theChampionDatacollection. - The result is collected into a vector using the
try_collectmethod, which allows for asynchronous processing of the cursor results.
§Related Functions:
get_champions_by_role: Retrieves champions filtered by a specific role from the collection.
§Dependencies:
- This function depends on a MongoDB collection that stores
ChampionDatadocuments. - Requires the
futurescrate for thetry_collectmethod to handle the cursor results asynchronously.