Skip to content

Instantly share code, notes, and snippets.

@PegasisForever
Created Oct 10, 2020
Embed
What would you like to do?
use mongodb::options::ClientOptions;
use mongodb::Client;
use mongodb::bson::doc;
use mongodb::bson::Document;
use std::time::Duration;
#[tokio::main]
async fn main() {
{
let mongo_options = ClientOptions::parse("mongodb://root:password@localhost:27018").await.unwrap();
let mongo_client = Client::with_options(mongo_options).unwrap();
let collection = mongo_client.database("test_db").collection("test");
let mut documents = vec![];
for _ in 0i32..=30000i32 {
let document: Document = doc! {
"a": 1,
"b": 1,
"c": 1,
"d": 1,
"e": 1,
"f": 1,
"g": 1,
"h": 1,
"i": 1,
"j": 1,
"k": 1,
};
documents.push(document);
}
collection.insert_many(documents, None).await.unwrap();
}
println!("dropped");
tokio::time::delay_for(Duration::from_secs(60)).await;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment