parent
1e7b685f64
commit
a669c9cfd9
@ -395,6 +395,17 @@ impl Query {
|
|||||||
.map_err(FieldError::from)
|
.map_err(FieldError::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn isUsernameUsed(context: &Context, username: String) -> FieldResult<bool> {
|
||||||
|
if !is_valid_user_name(&username) {
|
||||||
|
return Err(format!("{:?} is not a valid username", username).into());
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(sqlx::query(format!(
|
||||||
|
r#"SELECT user_name FROM users WHERE user_name="{}""#,
|
||||||
|
username,
|
||||||
|
).as_str()).fetch_optional(&context.db).await?.is_some())
|
||||||
|
}
|
||||||
|
|
||||||
async fn users(context: &Context) -> FieldResult<Vec<User>> {
|
async fn users(context: &Context) -> FieldResult<Vec<User>> {
|
||||||
let rows = sqlx::query("SELECT * FROM users")
|
let rows = sqlx::query("SELECT * FROM users")
|
||||||
.fetch_all(&context.db).await?;
|
.fetch_all(&context.db).await?;
|
||||||
|
Loading…
Reference in New Issue
Block a user