Function delete_follower

Source
async fn delete_follower(
    collection: &Collection<SummonerFollowedData>,
    followed_summoner: &SummonerFollowedData,
) -> Result<(), Error>
Expand description

⚙️ Function: Deletes a followed summoner from the database.

This asynchronous function removes a summoner from the follower_summoner collection in MongoDB based on their puuid. It logs the deletion action and ensures the summoner is no longer tracked in the database.

§Parameters:

  • collection: A reference to the MongoDB Collection<SummonerFollowedData>, used to interact with the database and delete the summoner data.
  • followed_summoner: A reference to a SummonerFollowedData struct, representing the summoner that is being deleted. The deletion is based on the summoner’s puuid.

§Returns:

  • Result<(), mongodb::error::Error>: Returns an empty result if successful, or an error if the deletion fails.

§Example:

This function is typically called when the follow time for a summoner has expired, and they need to be removed from the database:

delete_follower(&collection, &followed_summoner).await?;

§Notes:

  • The puuid field is used as the unique identifier for deletion from the MongoDB collection.
  • The function logs the puuid of the summoner being deleted using log::info!, which outputs the message to the standard log stream.