Move RocketDbPool
This commit is contained in:
parent
5c23cf7739
commit
60fdc78766
@ -23,12 +23,10 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-stream = { version = "^0.3" }
|
async-stream = { version = "^0.3" }
|
||||||
async-trait = { version = "0.1", optional = true }
|
|
||||||
chrono = { version = "^0", optional = true }
|
chrono = { version = "^0", optional = true }
|
||||||
futures = { version = "^0.3" }
|
futures = { version = "^0.3" }
|
||||||
futures-util = { version = "^0.3" }
|
futures-util = { version = "^0.3" }
|
||||||
log = { version = "^0.4", optional = true }
|
log = { version = "^0.4", optional = true }
|
||||||
rocket_db_pools = { git = "https://github.com/SergioBenitez/Rocket.git", optional = true }
|
|
||||||
rust_decimal = { version = "^1", optional = true }
|
rust_decimal = { version = "^1", optional = true }
|
||||||
sea-orm-macros = { version = "^0.1.1", path = "sea-orm-macros", optional = true }
|
sea-orm-macros = { version = "^0.1.1", path = "sea-orm-macros", optional = true }
|
||||||
sea-query = { version = "^0.16", features = ["thread-safe"] }
|
sea-query = { version = "^0.16", features = ["thread-safe"] }
|
||||||
@ -92,4 +90,3 @@ runtime-actix-rustls = ["sqlx/runtime-actix-rustls", "runtime-actix"]
|
|||||||
runtime-tokio = []
|
runtime-tokio = []
|
||||||
runtime-tokio-native-tls = ["sqlx/runtime-tokio-native-tls", "runtime-tokio"]
|
runtime-tokio-native-tls = ["sqlx/runtime-tokio-native-tls", "runtime-tokio"]
|
||||||
runtime-tokio-rustls = ["sqlx/runtime-tokio-rustls", "runtime-tokio"]
|
runtime-tokio-rustls = ["sqlx/runtime-tokio-rustls", "runtime-tokio"]
|
||||||
web-api-rocket = ["rocket_db_pools", "async-trait"]
|
|
||||||
|
@ -9,6 +9,7 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-stream = { version = "^0.3" }
|
async-stream = { version = "^0.3" }
|
||||||
|
async-trait = { version = "0.1" }
|
||||||
futures = { version = "^0.3" }
|
futures = { version = "^0.3" }
|
||||||
futures-util = { version = "^0.3" }
|
futures-util = { version = "^0.3" }
|
||||||
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", features = [
|
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", features = [
|
||||||
|
@ -12,7 +12,9 @@ use rocket_dyn_templates::{context, Template};
|
|||||||
|
|
||||||
use sea_orm::entity::*;
|
use sea_orm::entity::*;
|
||||||
use sea_orm::QueryOrder;
|
use sea_orm::QueryOrder;
|
||||||
use sea_orm::RocketDbPool;
|
|
||||||
|
mod pool;
|
||||||
|
use pool::RocketDbPool;
|
||||||
|
|
||||||
mod setup;
|
mod setup;
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ pub struct RocketDbPool {
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl rocket_db_pools::Pool for RocketDbPool {
|
impl rocket_db_pools::Pool for RocketDbPool {
|
||||||
type Error = crate::DbErr;
|
type Error = sea_orm::DbErr;
|
||||||
|
|
||||||
type Connection = crate::DatabaseConnection;
|
type Connection = sea_orm::DatabaseConnection;
|
||||||
|
|
||||||
async fn init(figment: &Figment) -> Result<Self, Self::Error> {
|
async fn init(figment: &Figment) -> Result<Self, Self::Error> {
|
||||||
let config = figment.extract::<Config>().unwrap();
|
let config = figment.extract::<Config>().unwrap();
|
||||||
@ -22,6 +22,6 @@ impl rocket_db_pools::Pool for RocketDbPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get(&self) -> Result<Self::Connection, Self::Error> {
|
async fn get(&self) -> Result<Self::Connection, Self::Error> {
|
||||||
Ok(crate::Database::connect(&self.db_url).await.unwrap())
|
Ok(sea_orm::Database::connect(&self.db_url).await.unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,8 +19,3 @@ pub use sqlx_mysql::*;
|
|||||||
pub use sqlx_postgres::*;
|
pub use sqlx_postgres::*;
|
||||||
#[cfg(feature = "sqlx-sqlite")]
|
#[cfg(feature = "sqlx-sqlite")]
|
||||||
pub use sqlx_sqlite::*;
|
pub use sqlx_sqlite::*;
|
||||||
|
|
||||||
#[cfg(feature = "web-api-rocket")]
|
|
||||||
mod rocket_db;
|
|
||||||
#[cfg(feature = "web-api-rocket")]
|
|
||||||
pub use rocket_db::*;
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user