diff --git a/Cargo.lock b/Cargo.lock index ed49ab8..6cdbe7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -239,7 +239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -277,7 +277,7 @@ dependencies = [ "parse-size", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -489,7 +489,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -538,7 +538,7 @@ checksum = "9aa0b287c8de4a76b691f29dbb5451e8dd5b79d777eaf87350c9b0cbfdb5e968" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -562,7 +562,7 @@ checksum = "7c7db3d5a9718568e4cf4a537cfd7070e6e6ff7481510d0237fb529ac850f6d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -902,7 +902,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -1019,7 +1019,7 @@ dependencies = [ "proc-macro2", "quote", "strum", - "syn 2.0.48", + "syn 2.0.69", "thiserror", ] @@ -1066,7 +1066,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -1077,7 +1077,7 @@ checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -1104,7 +1104,7 @@ dependencies = [ "derive_utils 0.14.1", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -1748,7 +1748,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.48", + "syn 2.0.69", "which", ] @@ -1867,9 +1867,9 @@ dependencies = [ [[package]] name = "bson" -version = "2.9.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce21468c1c9c154a85696bb25c20582511438edb6ad67f846ba1378ffdd80222" +checksum = "d8a88e82b9106923b5c4d6edfca9e7db958d4e98a478ec115022e81b9b38e2c8" dependencies = [ "ahash 0.8.11", "base64 0.13.1", @@ -2131,7 +2131,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2228,7 +2228,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2571,7 +2571,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2593,7 +2593,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2615,6 +2615,28 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +[[package]] +name = "db-diesel" +version = "1.0.0" +dependencies = [ + "actix-web", + "diesel", + "dotenvy", + "env_logger", + "log", + "serde", + "uuid", +] + +[[package]] +name = "db-mongo" +version = "1.0.0" +dependencies = [ + "actix-web", + "mongodb", + "serde", +] + [[package]] name = "db-postgres" version = "1.0.0" @@ -2718,7 +2740,7 @@ checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2762,7 +2784,7 @@ checksum = "9abcad25e9720609ccb3dcdb795d845e37d8ce34183330a9f48b03a1a71c8e21" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2773,7 +2795,7 @@ checksum = "61bb5a1014ce6dfc2a378578509abe775a5aa06bff584a547555d9efdb81b926" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2800,19 +2822,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "diesel-example" -version = "1.0.0" -dependencies = [ - "actix-web", - "diesel", - "dotenvy", - "env_logger", - "log", - "serde", - "uuid", -] - [[package]] name = "diesel_derives" version = "2.2.0" @@ -2823,7 +2832,7 @@ dependencies = [ "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2832,7 +2841,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25" dependencies = [ - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2855,7 +2864,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2884,7 +2893,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -3213,7 +3222,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", "unic-langid", ] @@ -3315,7 +3324,7 @@ checksum = "b0fa992f1656e1707946bbba340ad244f0814009ef8c0118eb7b658395f19a2e" dependencies = [ "frunk_proc_macro_helpers", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -3327,7 +3336,7 @@ dependencies = [ "frunk_core", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -3339,7 +3348,7 @@ dependencies = [ "frunk_core", "frunk_proc_macro_helpers", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -3469,7 +3478,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -4275,7 +4284,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5305557fa27b460072ae15ce07617e999f5879f14d376c8449f0bfb9f9d8e91e" dependencies = [ "derive_utils 0.13.2", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -4472,7 +4481,7 @@ checksum = "760dbe46660494d469023d661e8d268f413b2cb68c999975dcc237407096a693" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", "url", ] @@ -5003,18 +5012,9 @@ checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" [[package]] name = "mongodb" -version = "1.0.0" -dependencies = [ - "actix-web", - "mongodb 2.8.2", - "serde", -] - -[[package]] -name = "mongodb" -version = "2.8.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef206acb1b72389b49bc9985efe7eb1f8a9bb18e5680d262fac26c07f44025f1" +checksum = "bb4af699cbb12a221e978134999b16cbf030d964c3a7cd6c4af2584734190e58" dependencies = [ "async-trait", "base64 0.13.1", @@ -5029,8 +5029,9 @@ dependencies = [ "futures-util", "hex", "hmac", - "lazy_static", "md-5", + "mongodb-internal-macros", + "once_cell", "pbkdf2", "percent-encoding", "rand", @@ -5042,7 +5043,7 @@ dependencies = [ "serde_with", "sha-1", "sha2", - "socket2 0.4.10", + "socket2 0.5.5", "stringprep", "strsim 0.10.0", "take_mut", @@ -5057,6 +5058,17 @@ dependencies = [ "webpki-roots 0.25.4", ] +[[package]] +name = "mongodb-internal-macros" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1159486b5e1993138c385369c3c46f5608cb0b1c53734e503538366f3c4cedcc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.69", +] + [[package]] name = "multer" version = "2.1.0" @@ -5165,7 +5177,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", "termcolor", "thiserror", ] @@ -5449,7 +5461,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -5726,7 +5738,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -5833,7 +5845,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -5982,7 +5994,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -6045,9 +6057,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -6072,7 +6084,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -6549,7 +6561,7 @@ checksum = "853977598f084a492323fe2f7896b4100a86284ee8473612de60021ea341310f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -6886,7 +6898,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.48", + "syn 2.0.69", "toml 0.8.8", ] @@ -7078,7 +7090,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -7731,7 +7743,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -7763,9 +7775,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" dependencies = [ "proc-macro2", "quote", @@ -7976,7 +7988,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -8107,7 +8119,7 @@ checksum = "8d9ef545650e79f30233c0003bcc2504d7efac6dad25fca40744de773fe2049c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -8180,7 +8192,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -8496,7 +8508,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -8999,7 +9011,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -9080,7 +9092,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", "wasm-bindgen-shared", ] @@ -9114,7 +9126,7 @@ checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9767,7 +9779,7 @@ checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -9787,7 +9799,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] diff --git a/databases/diesel/Cargo.toml b/databases/diesel/Cargo.toml index bf294e4..08a77ff 100644 --- a/databases/diesel/Cargo.toml +++ b/databases/diesel/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "diesel-example" +name = "db-diesel" version = "1.0.0" edition = "2021" diff --git a/databases/mongodb/Cargo.toml b/databases/mongodb/Cargo.toml index 82bc650..75b2bec 100644 --- a/databases/mongodb/Cargo.toml +++ b/databases/mongodb/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "mongodb" +name = "db-mongo" version = "1.0.0" edition = "2021" [dependencies] actix-web.workspace = true -mongodb = "2" +mongodb = "3" serde.workspace = true diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md index c457818..7e1f8d5 100644 --- a/databases/mongodb/README.md +++ b/databases/mongodb/README.md @@ -1,6 +1,6 @@ # MongoDB -Simple example of MongoDB usage with Actix Web. For more information on the MongoDB Rust driver, visit the [documentation](https://docs.rs/mongodb/2.0.0/mongodb/index.html) and [source code](https://github.com/mongodb/mongo-rust-driver). +Simple example of MongoDB usage with Actix Web. For more information on the MongoDB Rust driver, visit the [documentation](https://docs.rs/mongodb/3) and [source code](https://github.com/mongodb/mongo-rust-driver). ## Usage diff --git a/databases/mongodb/src/main.rs b/databases/mongodb/src/main.rs index 2fbbf2f..d0236ef 100644 --- a/databases/mongodb/src/main.rs +++ b/databases/mongodb/src/main.rs @@ -15,7 +15,7 @@ const COLL_NAME: &str = "users"; #[post("/add_user")] async fn add_user(client: web::Data, form: web::Form) -> HttpResponse { let collection = client.database(DB_NAME).collection(COLL_NAME); - let result = collection.insert_one(form.into_inner(), None).await; + let result = collection.insert_one(form.into_inner()).await; match result { Ok(_) => HttpResponse::Ok().body("user added"), Err(err) => HttpResponse::InternalServerError().body(err.to_string()), @@ -27,10 +27,7 @@ async fn add_user(client: web::Data, form: web::Form) -> HttpRespo async fn get_user(client: web::Data, username: web::Path) -> HttpResponse { let username = username.into_inner(); let collection: Collection = client.database(DB_NAME).collection(COLL_NAME); - match collection - .find_one(doc! { "username": &username }, None) - .await - { + match collection.find_one(doc! { "username": &username }).await { Ok(Some(user)) => HttpResponse::Ok().json(user), Ok(None) => { HttpResponse::NotFound().body(format!("No user found with username {username}")) @@ -49,7 +46,7 @@ async fn create_username_index(client: &Client) { client .database(DB_NAME) .collection::(COLL_NAME) - .create_index(model, None) + .create_index(model) .await .expect("creating an index should succeed"); } diff --git a/databases/mongodb/src/test.rs b/databases/mongodb/src/test.rs index 3fbd51e..14e5f21 100644 --- a/databases/mongodb/src/test.rs +++ b/databases/mongodb/src/test.rs @@ -16,7 +16,7 @@ async fn test() { client .database(DB_NAME) .collection::(COLL_NAME) - .drop(None) + .drop() .await .expect("drop collection should succeed");