use sqlx::{MySqlPool, Result, Row, mysql::MySqlRow}; pub async fn get_cid(user: String, filename: String, pool: &MySqlPool) -> Result { let q: String = sqlx::query("SELECT cid FROM memes WHERE user = ? AND filename = ? ORDER BY id DESC").bind(user).bind(filename) .map(|row: MySqlRow| row.get("cid")) .fetch_one(pool).await?; Ok(q) } pub async fn get_memes(user: String, pool: &MySqlPool) -> Result> { let q: Vec = sqlx::query("SELECT filename FROM memes WHERE user = ? ORDER BY filename").bind(user) .map(|row: MySqlRow| row.get("filename")) .fetch_all(pool).await?; Ok(q) } pub async fn get_users(pool: &MySqlPool) -> Result> { let q: Vec = sqlx::query("SELECT id FROM users ORDER BY id") .map(|row: MySqlRow| row.get("id")) .fetch_all(pool).await?; Ok(q) }