How to use MongoDB with Rust

Connect Rust to MongoDB using the mongodb crate with bson-3 support and serde for data serialization.

Use the mongodb crate with the bson-3 feature to connect and interact with MongoDB in Rust.

[dependencies]
mongodb = { version = "3.3.0", default-features = false, features = ["bson-3", "compat-3-3-0", "rustls-tls"] }
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.0", features = ["full"] }
use mongodb::{Client, bson::doc};
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize)]
struct Member {
    #[serde(rename = "_id")]
    id: u32,
    name: String,
    active: bool,
}

#[tokio::main]
async fn main() {
    let client = Client::with_uri_str("mongodb://admin:password@127.0.0.1:27017/?authSource=admin").await.unwrap();
    let collection = client.database("axum-mongo").collection::<Member>("members");
    collection.insert_one(Member { id: 1, name: "Alice".to_string(), active: true }).await.unwrap();
}