init serv file
This commit is contained in:
14
packages/serv/src/utils/database.rs
Normal file
14
packages/serv/src/utils/database.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use actix_web::web;
|
||||
use actix_web::web::Data;
|
||||
use r2d2::{Pool, State};
|
||||
use r2d2_sqlite::SqliteConnectionManager;
|
||||
|
||||
pub struct SqliteState {
|
||||
pool: Pool<SqliteConnectionManager>,
|
||||
}
|
||||
|
||||
pub fn init_database() -> Data<SqliteState> {
|
||||
let db = SqliteConnectionManager::file("./database.mod");
|
||||
let pool = Pool::new(db).unwrap();
|
||||
Data::new(SqliteState { pool: pool.clone() })
|
||||
}
|
||||
Reference in New Issue
Block a user