I want this fuction to return true of a row containing the email
is found in the database. Here is the code
func UserExists(email string) bool {
var err error
user := model.User{}
err = shared.Dbmap.Get(&user, "SELECT * FROM user WHERE email=? LIMIT 1", email)
if err == nil {
fmt.Println("User is already in DB")
return true
} else {
fmt.Println("No rows returned")
return false
}
}
However, it always returns false
even if there is such email in the db, so clearly the query is not up to the job. How can I fix this?