pub async fn extract_database_name(
connection_string: &str,
) -> Result<Option<String>>Expand description
Extract database name from MongoDB connection string
Parses the connection string and extracts the database name. MongoDB connection strings can have the database name in the path.
§Arguments
connection_string- MongoDB connection URL
§Returns
Database name if present in URL, None otherwise
§Examples
assert_eq!(
extract_database_name("mongodb://localhost:27017/mydb").await?,
Some("mydb".to_string())
);
assert_eq!(
extract_database_name("mongodb://localhost:27017").await?,
None
);