Add create chat function

Co-authored-by: Elias Schriefer <EliasSchriefer@users.noreply.github.com>
This commit is contained in:
Erik Foris 2021-10-25 18:16:07 +02:00
parent c52160ab69
commit 9608451145

View File

@ -1,12 +1,10 @@
use uuid::Uuid;
use std::path::PathBuf; use std::path::PathBuf;
use sqlx::{ use sqlx::sqlite::{
sqlite::{ SqlitePool,
SqlitePool, SqliteConnectOptions,
SqliteConnectOptions, SqliteQueryResult,
SqliteQueryResult, SqliteSynchronous,
SqliteSynchronous,
},
//Row,
}; };
/// Prepare sqlite database connection /// Prepare sqlite database connection
@ -30,6 +28,10 @@ pub async fn load_template(sqlite_handle: &SqlitePool) -> sqlx::Result<SqliteQue
)).execute(sqlite_handle).await )).execute(sqlite_handle).await
} }
//pub async fn sqlite_out(sqlite_handle: &SqlitePool, query:&str, index:usize) -> Result<String, sqlx::Error> { /// Create message table from template
// sqlx::query(query).fetch_one(sqlite_handle).await.unwrap().try_get(index) pub async fn create_chat(sqlite_handle: &SqlitePool, uuid: &Uuid) -> sqlx::Result<SqliteQueryResult> {
//} sqlx::query(format!(
include_str!("msgdata_template.sql"),
chat_id = uuid.to_simple(),
).as_str()).execute(sqlite_handle).await
}