pub async fn get_followed_summoners(
collection: &Collection<SummonerFollowedData>,
) -> Result<Vec<SummonerFollowedData>, Error>Expand description
⚙️ Function: Retrieves all followed summoners from the database.
This asynchronous function queries the “follower_summoner” collection in the “stat-summoner” MongoDB database
to retrieve all documents representing followed summoners. It collects each SummonerFollowedData into a vector.
§Parameters:
collection: A reference to the MongoDB collection containingSummonerFollowedDatadocuments.
§Returns:
Result<Vec<SummonerFollowedData>, mongodb::error::Error>: A vector of followed summoners if successful, or an error if the query fails.
§⚠️ Notes:
- Prints an error message in French if a document retrieval fails.
- Ensure that the
SummonerFollowedDatastruct aligns with the collection’s document structure.
§Example:
let summoners = get_followed_summoners(&collection).await?;
println!("Retrieved {} summoners.", summoners.len());