ch12.2
This commit is contained in:
@@ -69,5 +69,11 @@ func (m *UserModel) Authenticate(email, password string) (int, error) {
|
||||
}
|
||||
|
||||
func (m *UserModel) Exists(id int) (bool, error) {
|
||||
return false, nil
|
||||
var exists bool
|
||||
|
||||
stmt := `SELECT EXISTS(SELECT true FROM users WHERE id = ?)`
|
||||
|
||||
err := m.DB.QueryRow(stmt, id).Scan(&exists)
|
||||
|
||||
return exists, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user