Created
February 26, 2015 01:14
-
-
Save c4milo/5bdd3788db601b19fb89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GetByID returns an Account instance given its id which is either: | |
// username or email. | |
func (r *RepoPostgres) GetByID(id string) (*Account, error) { | |
a := new(account) | |
err := r.db.Get(a, "SELECT * FROM accounts WHERE username = $1 OR email = $1", id) | |
if err != nil { | |
return nil, translateError(err) | |
} | |
a.Account.PictureURL, _ = url.Parse(a.PictureURL) | |
a.Account.Type = AccountType(a.Type) | |
a.Account.Status = StatusType(a.Status) | |
return &(a.Account), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment