diff --git a/src/main.rs b/src/main.rs index 112d487..fc26503 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,19 +11,21 @@ async fn main() { // Manually set an option. client_options.app_name = Some("My App".to_string()); - client_options.credential = Some(Credential::default()); - client_options.credential.as_mut().unwrap().username = Some(std::env::var("mongo_username").unwrap()); - client_options.credential.as_mut().unwrap().password = Some(std::env::var("mongo_password").unwrap()); + + let credential_builder = Credential::builder() + .username(Some(std::env::var("mongo_username").unwrap())) + .password(Some(std::env::var("mongo_password").unwrap())); + + client_options.credential = Some(credential_builder.build()); // Get a handle to the deployment. let client = Client::with_options(client_options).unwrap(); - let db = client.database("test"); - match db.create_collection("test", None).await { Err(_) => panic!("ERROR: incorrect usage"), _ => {} - } + } + let collection = db.collection::("test"); loop { diff --git a/src/test.json b/src/test.json deleted file mode 100644 index 4bfdb82..0000000 --- a/src/test.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": 1, - "first_name": "Tom", - "last_name": "Cruise", - "photo": "https://jsonformatter.org/img/tom-cruise.jpg" -}, -{ - "id": 2, - "first_name": "Maria", - "last_name": "Sharapova", - "photo": "https://jsonformatter.org/img/Maria-Sharapova.jpg - " -}, -{ - "id": 3, - "first_name": "Robert", - "last_name": "Downey Jr", - "photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg" -} \ No newline at end of file