Crate bb8_mongodb

source ·
Expand description

A bb8 connection manager for a MongoDB connection pool

** NOTE ** - The bb8 version has been pinned to 0.8.1 for now due to bugs causing tokio timeouts.

§Example

// Setup the MongoDB `ClientOptions`
let mut client_options = ClientOptions::parse(url).await?;
client_options.credential = Some(
    Credential::builder()
        .username(user)
        .password(password)
        .build(),
);

// Setup the `bb8-mongodb` connection manager
let connection_manager = MongodbConnectionManager::new(client_options, "admin");
// Setup the `bb8` connection pool
let pool = Pool::builder().build(connection_manager).await?;
// Connect
let conn = pool.get().await?;
assert_eq!(conn.name(), "admin");
// Run a command
let doc = conn.run_command(doc! { "ping": 1 }, None).await?;
// Check the result
assert_eq!(doc! { "ok": 1 }, doc);

Structs§

Enums§