use super::{Database, DatabaseError, queries};
use rusqlite::params;

impl Database {
    db_exec!(fn set_host(key: &str, value: &str), queries::upsert_host);

    pub fn get_host(&mut self, key: &str) -> Result<Option<String>, DatabaseError> {
        let entry = self.query_opt(&queries::find_host, params![key])?;
        Ok(entry.map(|e| e.value))
    }
}
