feat: implement email exists for sqlx postgres

This commit is contained in:
realaravinth 2022-05-11 13:31:31 +05:30
parent 9595ea232b
commit 84671c4a11
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88

View file

@ -156,6 +156,24 @@ impl MCDatabase for Database {
Ok(resp)
}
/// check if email exists
async fn email_exists(&self, email: &str) -> DBResult<bool> {
let res = sqlx::query!(
"SELECT EXISTS (SELECT 1 from mcaptcha_users WHERE email = $1)",
email
)
.fetch_one(&self.pool)
.await
.map_err(map_register_err)?;
let mut resp = false;
if let Some(x) = res.exists {
resp = x;
}
Ok(resp)
}
}
fn now_unix_time_stamp() -> i64 {