mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
examples: Update to diesel-async 0.6 (#3470)
This commit is contained in:
@@ -6,9 +6,8 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
axum = { path = "../../axum", features = ["macros"] }
|
||||
bb8 = "0.8"
|
||||
diesel = "2"
|
||||
diesel-async = { version = "0.5", features = ["postgres", "bb8"] }
|
||||
diesel-async = { version = "0.6", features = ["postgres", "bb8"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
tracing = "0.1"
|
||||
|
||||
@@ -21,7 +21,8 @@ use axum::{
|
||||
};
|
||||
use diesel::prelude::*;
|
||||
use diesel_async::{
|
||||
pooled_connection::AsyncDieselConnectionManager, AsyncPgConnection, RunQueryDsl,
|
||||
pooled_connection::{bb8, AsyncDieselConnectionManager},
|
||||
AsyncPgConnection, RunQueryDsl,
|
||||
};
|
||||
use std::net::SocketAddr;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
@@ -49,7 +50,7 @@ struct NewUser {
|
||||
hair_color: Option<String>,
|
||||
}
|
||||
|
||||
type Pool = bb8::Pool<AsyncDieselConnectionManager<AsyncPgConnection>>;
|
||||
type Pool = bb8::Pool<AsyncPgConnection>;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@@ -97,9 +98,7 @@ async fn create_user(
|
||||
|
||||
// we can also write a custom extractor that grabs a connection from the pool
|
||||
// which setup is appropriate depends on your application
|
||||
struct DatabaseConnection(
|
||||
bb8::PooledConnection<'static, AsyncDieselConnectionManager<AsyncPgConnection>>,
|
||||
);
|
||||
struct DatabaseConnection(bb8::PooledConnection<'static, AsyncPgConnection>);
|
||||
|
||||
impl<S> FromRequestParts<S> for DatabaseConnection
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user