summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/mongodb/Cargo.toml4
-rw-r--r--examples/mongodb/src/main.rs15
2 files changed, 10 insertions, 9 deletions
diff --git a/examples/mongodb/Cargo.toml b/examples/mongodb/Cargo.toml
index c5164707..c084a36f 100644
--- a/examples/mongodb/Cargo.toml
+++ b/examples/mongodb/Cargo.toml
@@ -6,9 +6,9 @@ publish = false
[dependencies]
axum = { path = "../../axum" }
-mongodb = "2.8.0"
+mongodb = "3.1.0"
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.0", features = ["full"] }
-tower-http = { version = "0.5.0", features = ["add-extension", "trace"] }
+tower-http = { version = "0.6.1", features = ["add-extension", "trace"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
diff --git a/examples/mongodb/src/main.rs b/examples/mongodb/src/main.rs
index 973aec1c..2cf25f4f 100644
--- a/examples/mongodb/src/main.rs
+++ b/examples/mongodb/src/main.rs
@@ -30,7 +30,7 @@ async fn main() {
// pinging the database
client
.database("axum-mongo")
- .run_command(doc! { "ping": 1 }, None)
+ .run_command(doc! { "ping": 1 })
.await
.unwrap();
println!("Pinged your database. Successfully connected to MongoDB!");
@@ -38,8 +38,9 @@ async fn main() {
// logging middleware
tracing_subscriber::registry()
.with(
- tracing_subscriber::EnvFilter::try_from_default_env()
- .unwrap_or_else(|_| "example_mongo=debug,tower_http=debug".into()),
+ tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
+ format!("{}=debug,tower_http=debug", env!("CARGO_CRATE_NAME")).into()
+ }),
)
.with(tracing_subscriber::fmt::layer())
.init();
@@ -70,7 +71,7 @@ async fn create_member(
State(db): State<Collection<Member>>,
Json(input): Json<Member>,
) -> Result<Json<InsertOneResult>, (StatusCode, String)> {
- let result = db.insert_one(input, None).await.map_err(internal_error)?;
+ let result = db.insert_one(input).await.map_err(internal_error)?;
Ok(Json(result))
}
@@ -81,7 +82,7 @@ async fn read_member(
Path(id): Path<u32>,
) -> Result<Json<Option<Member>>, (StatusCode, String)> {
let result = db
- .find_one(doc! { "_id": id }, None)
+ .find_one(doc! { "_id": id })
.await
.map_err(internal_error)?;
@@ -94,7 +95,7 @@ async fn update_member(
Json(input): Json<Member>,
) -> Result<Json<UpdateResult>, (StatusCode, String)> {
let result = db
- .replace_one(doc! { "_id": input.id }, input, None)
+ .replace_one(doc! { "_id": input.id }, input)
.await
.map_err(internal_error)?;
@@ -107,7 +108,7 @@ async fn delete_member(
Path(id): Path<u32>,
) -> Result<Json<DeleteResult>, (StatusCode, String)> {
let result = db
- .delete_one(doc! { "_id": id }, None)
+ .delete_one(doc! { "_id": id })
.await
.map_err(internal_error)?;