diff --git a/server/src/db.rs b/server/src/db.rs index 7c5fcf4..7c9b548 100644 --- a/server/src/db.rs +++ b/server/src/db.rs @@ -3,100 +3,7 @@ use leptos::*; use serde::*; use sqlx::*; -// pub async fn db_build(pool: &SqlitePool) -> Result<(), ServerFnError> { -// let _res = query( -// " -// CREATE TABLE -// blog ( -// content_type TEXT, -// title TEXT, -// date TEXT, -// content TEXT -// ) -// ", -// ) -// .execute(pool) -// .await?; -// -// // println!("{:?}", _res); -// -// #[derive(Deserialize)] -// struct ArticleFrontmatter { -// content_type: String, -// title: String, -// date: String, -// } -// -// for file in std::fs::read_dir("./public/blog".to_string())? { -// let fileinfo = file?; -// let filepath = fileinfo.path(); -// -// if let Some(filetype) = filepath.extension() { -// if filetype == "md" { -// let file = std::fs::read_to_string(filepath)?; -// let html_from_md = -// femark::process_markdown_to_html_with_frontmatter(&file.to_string(), true) -// .expect("Problem processing markdown"); -// let content = html_from_md.content; -// let _toc = html_from_md.toc; -// -// if let Some(front_raw) = html_from_md.frontmatter { -// if let Some(front_code) = front_raw.code_block { -// let toml: ArticleFrontmatter = toml::from_str(&front_code.source)?; -// -// let article = Article { -// content_type: toml.content_type, -// title: toml.title, -// date: toml.date, -// content, -// }; -// -// let _res = sqlx::query( -// " -// INSERT INTO -// blog (content_type, title, date, content) -// VALUES -// ($1, $2, $3, $4) -// ", -// ) -// .bind(article.content_type) -// .bind(article.title) -// .bind(article.date) -// .bind(article.content) -// .execute(pool) -// .await?; -// -// // println!("{:?}", _res); -// } -// } -// } -// } -// } -// -// Ok(()) -// } - -pub async fn start_pool() -> Result { - println!( - " -⠄⠄⠄⠄⢀⡤⣖⣞⣮⢾⢽⣳⢯⢿⢷⣦⣄⠄⠄⠐⠄ -⠐⠄⠄⣴⣯⣯⢷⣻⣺⢽⣫⢾⣝⡵⡯⣾⣽⢷⣄⠄⠄ -⠄⢀⣼⢿⡽⣾⢯⣷⣻⣽⢽⣳⣳⢽⡺⡮⣫⢯⢿⣦⠄ -⠄⣼⣿⢽⡯⣿⡽⣾⡿⣞⣯⢷⢯⢯⢯⢯⡺⡪⡳⣻⠄ -⣴⣿⣿⣽⣟⣷⣟⣯⣿⡽⣞⣯⢿⡽⡽⡵⣝⢮⣫⣺⠄ -⠄⠄⠉⠉⠛⠛⠛⠛⠛⠻⠿⠿⠿⣿⣿⡿⣿⣽⣾⣾⡀ -⠐⡀⠢⠄⡀⠄⢀⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⠣ -⡀⠂⠈⣪⣌⡤⢾⠿⠕⢤⣤⣨⣠⢤⠡⠄⠄⡌⠄⡐⡐ -⠐⠈⠄⠱⣻⡻⠶⢦⠶⠯⠟⢟⢯⢳⢩⡂⡆⡇⡐⡐⢌ -⢁⠐⠄⠈⣾⣓⢝⣛⡛⡗⣞⣗⢕⡕⢕⠕⡸⡀⠂⠌⡂ -⡀⠂⡁⠄⡿⣕⢷⣻⢽⢝⢞⢮⢳⠑⠅⢑⢜⠜⣬⢐⢈ -⠄⢁⣀⣴⠋⠪⠳⠹⠵⠹⠘⠈⠂⠁⡐⡸⡘⣠⡳⡣⣪ -⣽⢟⣿⡣⠄⢸⡄⠠⠠⡠⢠⢐⠨⡐⣴⣹⡨⣞⣎⢎⢺ -⠏⠟⠛⠃⠄⠘⠛⠊⠊⠘⠐⠅⠇⠻⠛⠓⠛⠛⠪⠓⠹ -db goin up" - ); - let pool = SqlitePool::connect("sqlite::memory:").await?; - +pub async fn db_build(pool: &SqlitePool) -> Result<(), ServerFnError> { let _res = query( " CREATE TABLE @@ -108,7 +15,7 @@ db goin up" ) ", ) - .execute(&pool) + .execute(pool) .await?; // println!("{:?}", _res); @@ -156,7 +63,7 @@ db goin up" .bind(article.title) .bind(article.date) .bind(article.content) - .execute(&pool) + .execute(pool) .await?; // println!("{:?}", _res); @@ -166,5 +73,32 @@ db goin up" } } + Ok(()) +} + +pub async fn start_pool() -> Result { + println!( + " +⠄⠄⠄⠄⢀⡤⣖⣞⣮⢾⢽⣳⢯⢿⢷⣦⣄⠄⠄⠐⠄ +⠐⠄⠄⣴⣯⣯⢷⣻⣺⢽⣫⢾⣝⡵⡯⣾⣽⢷⣄⠄⠄ +⠄⢀⣼⢿⡽⣾⢯⣷⣻⣽⢽⣳⣳⢽⡺⡮⣫⢯⢿⣦⠄ +⠄⣼⣿⢽⡯⣿⡽⣾⡿⣞⣯⢷⢯⢯⢯⢯⡺⡪⡳⣻⠄ +⣴⣿⣿⣽⣟⣷⣟⣯⣿⡽⣞⣯⢿⡽⡽⡵⣝⢮⣫⣺⠄ +⠄⠄⠉⠉⠛⠛⠛⠛⠛⠻⠿⠿⠿⣿⣿⡿⣿⣽⣾⣾⡀ +⠐⡀⠢⠄⡀⠄⢀⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⠣ +⡀⠂⠈⣪⣌⡤⢾⠿⠕⢤⣤⣨⣠⢤⠡⠄⠄⡌⠄⡐⡐ +⠐⠈⠄⠱⣻⡻⠶⢦⠶⠯⠟⢟⢯⢳⢩⡂⡆⡇⡐⡐⢌ +⢁⠐⠄⠈⣾⣓⢝⣛⡛⡗⣞⣗⢕⡕⢕⠕⡸⡀⠂⠌⡂ +⡀⠂⡁⠄⡿⣕⢷⣻⢽⢝⢞⢮⢳⠑⠅⢑⢜⠜⣬⢐⢈ +⠄⢁⣀⣴⠋⠪⠳⠹⠵⠹⠘⠈⠂⠁⡐⡸⡘⣠⡳⡣⣪ +⣽⢟⣿⡣⠄⢸⡄⠠⠠⡠⢠⢐⠨⡐⣴⣹⡨⣞⣎⢎⢺ +⠏⠟⠛⠃⠄⠘⠛⠊⠊⠘⠐⠅⠇⠻⠛⠓⠛⠛⠪⠓⠹ +db goin up" + ); + + let pool = SqlitePool::connect("sqlite://doordesk.db").await?; + + let _ = db_build(&pool); + Ok(pool) }