Macro mongodb_macro::database_config
source · macro_rules! database_config { ($opts:ident) => { ... }; ($opts:ident; ($db_url:tt, $db_name:tt)) => { ... }; }
Expand description
Creates a new configuration structure to initialize the MongoDB database
Create a new configuration structure to initialize the MongoDB database with a standard environment variable
mongodb_macro::database_config!(Opts);
fn main() {
std::env::set_var("DB_URL", "mongodb://root:root@localhost:27017");
std::env::set_var("DB_NAME", "test");
let opts = Opts::parse();
}
Create a new configuration structure to initialize the MongoDB database with the specified environment variable
mongodb_macro::database_config!(Opts; ("MONGO_DB_URL", "MONGO_DB_NAME"));
fn main() {
std::env::set_var("MONGO_DB_URL", "mongodb://root:root@localhost:27017");
std::env::set_var("MONGO_DB_NAME", "test");
let opts = Opts::parse();
}