* added example for axum + graphql * clean up * removed macos file * Pr/587 (#1) * Migrate on startup * Update CI * Add .gitignore * Add README Co-authored-by: Billy Chan <ccw.billy.123@gmail.com> Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
21 lines
465 B
Rust
21 lines
465 B
Rust
use entity::sea_orm;
|
|
use sea_orm::DatabaseConnection;
|
|
|
|
pub struct Database {
|
|
pub connection: DatabaseConnection,
|
|
}
|
|
|
|
impl Database {
|
|
pub async fn new() -> Self {
|
|
let connection = sea_orm::Database::connect(std::env::var("DATABASE_URL").unwrap())
|
|
.await
|
|
.expect("Could not connect to database");
|
|
|
|
Database { connection }
|
|
}
|
|
|
|
pub fn get_connection(&self) -> &DatabaseConnection {
|
|
&self.connection
|
|
}
|
|
}
|