Skip to content

Instantly share code, notes, and snippets.

@PegasisForever
Created October 10, 2020 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PegasisForever/95ca0e3cb25336f9f48227a090ef41ce to your computer and use it in GitHub Desktop.
Save PegasisForever/95ca0e3cb25336f9f48227a090ef41ce to your computer and use it in GitHub Desktop.
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