- Add #![allow(dead_code)] to modules with future features - Fix trailing whitespace in main.rs - Remove unused imports (Claims, ObjectId, Deserialize, Serialize) - Fix unnecessary map_err in health_stats.rs - Add allow attributes for experimental and redundant code - Fix redundant pattern matching in health.rs
31 lines
730 B
Rust
31 lines
730 B
Rust
#![allow(dead_code)]
|
|
#![allow(clippy::useless_conversion)]
|
|
use anyhow::Result;
|
|
use mongodb::{Client, Database};
|
|
use std::env;
|
|
|
|
pub mod appointment;
|
|
pub mod family;
|
|
pub mod health_data;
|
|
pub mod lab_result;
|
|
pub mod medication;
|
|
pub mod permission;
|
|
pub mod profile;
|
|
pub mod share;
|
|
pub mod user;
|
|
|
|
pub mod init; // Database initialization module
|
|
|
|
mod mongodb_impl;
|
|
|
|
pub use mongodb_impl::MongoDb;
|
|
|
|
pub async fn create_database() -> Result<Database> {
|
|
let mongo_uri = env::var("MONGODB_URI").expect("MONGODB_URI must be set");
|
|
let db_name = env::var("DATABASE_NAME").expect("DATABASE_NAME must be set");
|
|
|
|
let client = Client::with_uri_str(&mongo_uri).await?;
|
|
let database = client.database(&db_name);
|
|
|
|
Ok(database)
|
|
}
|