-
Hello. I want to check if a record exists in my PostgreSQL database. pub async fn nickname_exist(db: &PgPool, nickname: &String) -> Result<bool> {
let is_exist =
sqlx::query(r#"SELECT exists (SELECT 1 FROM users WHERE nickname = $1 LIMIT 1)"#)
.bind(nickname)
.map(|r: PgRow| r.get(0)) // I was confused here.
.fetch_one(db)
.await?;
println!("{:?}", is_exist);
Ok(true)
} I was confused by |
Beta Was this translation helpful? Give feedback.
Answered by
xiayulu
Nov 18, 2021
Replies: 1 comment
-
Fine. I solved this problem by test in pgadmin: So the column name is Hope This may Some one else. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
xiayulu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fine. I solved this problem by test in pgadmin:
So the column name is
exists
.Hope This may Some one else.