use crate::SupabaseClient;
use serde_json::Value;
impl SupabaseClient {
pub async fn get_id(
&self,
email: String,
table_name: String,
column_name: String,
) -> Result<String, String> {
let response: Result<Vec<Value>, String> = self
.select(&table_name)
.eq(&column_name, &email)
.execute()
.await;
match response {
Ok(response) => {
if !response.is_empty() {
let id: String = response[0]["id"].to_string();
Ok(id)
} else {
Err("No matching record found".to_owned())
}
}
Err(error) => Err(error),
}
}
}