Skip to content
1        10        20        30        40        50        60        701use crate::db::Database;23impl Database {4    pub async fn create_invite(&self, token: &str) -> Result<(), String> {5        self.conn()6            .await?7            .execute(8                "INSERT INTO invites (token, created_at) VALUES (?1, ?2)",9                turso::params![token, chrono::Utc::now().to_rfc3339()],10            )11            .await12            .map_err(|e| e.to_string())?;13        Ok(())14    }1516    pub async fn invite_exists(&self, token: &str) -> Result<bool, String> {17        let mut rows = self18            .conn()19            .await?20            .query(21                "SELECT 1 FROM invites WHERE token = ?1",22                turso::params![token],23            )24            .await25            .map_err(|e| e.to_string())?;26        Ok(rows.next().await.map_err(|e| e.to_string())?.is_some())27    }28}