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