diff options
author | fxqnlr <[email protected]> | 2022-10-31 22:41:18 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2022-10-31 22:41:18 +0100 |
commit | fc1cb1acc0dce412e948475002666bcd1d4b0348 (patch) | |
tree | 6b7667b453af8f2065681fa4dd850b0675b7bbde /src/db.rs | |
parent | 3320da719669f37dd5f55693b4d76edb27dbce02 (diff) | |
download | modlist-fc1cb1acc0dce412e948475002666bcd1d4b0348.tar modlist-fc1cb1acc0dce412e948475002666bcd1d4b0348.tar.gz modlist-fc1cb1acc0dce412e948475002666bcd1d4b0348.zip |
add first impl
Diffstat (limited to 'src/db.rs')
-rw-r--r-- | src/db.rs | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,18 @@ | |||
1 | use crate::Modloader; | ||
2 | |||
3 | pub fn insert_mod(id: String, name: String, current_version: String, old_versions: Vec<String>, mod_loader: Modloader, desired_mc_version: String) -> Result<(), sqlite::Error> { | ||
4 | |||
5 | let connection = sqlite::open("./data.db").unwrap(); | ||
6 | |||
7 | let loader = match mod_loader { | ||
8 | Modloader::Fabric => "fabric", | ||
9 | Modloader::Forge => "forge", | ||
10 | }; | ||
11 | |||
12 | let sql = format!("INSERT INTO mods VALUES ('{}', '{}', '{}', '{}', '{}', '{}')", id, name, current_version, old_versions.join("|"), loader, desired_mc_version); | ||
13 | |||
14 | dbg!(&sql); | ||
15 | |||
16 | connection.execute(sql) | ||
17 | |||
18 | } | ||