Aaron Leopold 7ba6144ead
Added axum graphql example (#587)
* 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>
2022-03-16 18:16:19 +08:00

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
}
}