pub async fn read_collection_data(
database: &Database,
collection_name: &str,
) -> Result<Vec<Document>>Expand description
Read all documents from a MongoDB collection
Reads all documents from the collection and returns them as BSON documents. For large collections, this may consume significant memory.
§Arguments
database- MongoDB database referencecollection_name- Collection name (must be validated)
§Returns
Vector of BSON documents from the collection
§Security
- Collection name is validated before querying
- Read-only operation, no modifications possible
§Examples
let client = connect_mongodb("mongodb://localhost:27017/mydb").await?;
let db = client.database("mydb");
let collection = "users";
validate_table_name(collection)?;
let documents = read_collection_data(&db, collection).await?;
println!("Read {} documents", documents.len());