Skip to content

Commit 3a9121f

Browse files
committed
wip
1 parent 908a940 commit 3a9121f

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

src/utils/create_project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn create_files(project_path: &Path, user_selected: UserSelected, data: &Object)
144144
write_file(&file.data, &file_path, data)?;
145145
} else if filename.starts_with("_data/") {
146146
if filename.contains(user_selected.db_lib.to_string().as_str())
147-
|| filename.contains(user_selected.db_type.to_string().as_str())
147+
&& filename.contains(user_selected.db_type.to_string().as_str())
148148
{
149149
let file = Template::get(filename.as_ref()).expect("file must exist");
150150
let file_path = project_path.join(filename.as_ref().trim_start_matches("_"));

src/utils/get_selection.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,21 @@ pub fn get_user_selected() -> Result<Option<UserSelected>> {
4949
1 => DbLib::SeaOrm,
5050
2 => DbLib::Diesel,
5151
3 => DbLib::Rbatis,
52+
4 => DbLib::Mongodb,
5253
_ => anyhow::bail!("Invalid db connection type selection"),
5354
};
54-
let mut db_types: Vec<&str> = vec!["sqlite", "mysql", "postgres"];
55-
if db_lib == DbLib::Rbatis {
56-
db_types = vec!["sqlite", "mysql", "postgres", "mssql"];
55+
if db_lib == DbLib::Mongodb {
56+
return Ok(Some(UserSelected {
57+
code_gen,
58+
db_type: DbType::Mongodb,
59+
db_lib,
60+
}));
5761
}
62+
63+
let mut db_types: Vec<&str> = vec!["sqlite", "mysql", "postgres"];
64+
// if db_lib == DbLib::Rbatis {
65+
// db_types = vec!["sqlite", "mysql", "postgres", "mssql"];
66+
// }
5867
let db_type_selection = Select::with_theme(&theme)
5968
.with_prompt(t!("select_db_type").replace(r"\n", "\n"))
6069
.default(0)
@@ -64,7 +73,6 @@ pub fn get_user_selected() -> Result<Option<UserSelected>> {
6473
0 => DbType::Sqlite,
6574
1 => DbType::Mysql,
6675
2 => DbType::Postgres,
67-
3 => DbType::Mongodb,
6876
_ => anyhow::bail!("Invalid db type selection"),
6977
};
7078

@@ -96,7 +104,9 @@ pub enum DbLib {
96104
#[strum(serialize = "diesel")]
97105
Diesel,
98106
#[strum(serialize = "rbatis")]
99-
Rbatis
107+
Rbatis,
108+
#[strum(serialize = "mongodb")]
109+
Mongodb
100110
}
101111

102112
#[derive(Debug, PartialEq, Clone, Copy, strum::Display)]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)