list_collections

Function list_collections 

Source
pub async fn list_collections(
    client: &Client,
    db_name: &str,
) -> Result<Vec<String>>
Expand description

List all collection names in a MongoDB database

Retrieves names of all collections in the specified database. System collections (starting with “system.”) are excluded.

§Arguments

  • client - MongoDB client connection
  • db_name - Database name to list collections from

§Returns

Vector of collection names

§Security

Only lists user collections, system collections are excluded

§Examples

let client = connect_mongodb("mongodb://localhost:27017/mydb").await?;
let collections = list_collections(&client, "mydb").await?;
println!("Found {} collections", collections.len());