We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The db.Query and db.QueryOne expects a struct to populate. For a simple select count(*) query, what would you recommend?
My attempt:
type QueryResult struct { Count int } qr := QueryResult{} _, err := db.QueryOne(&qr, `SELECT COUNT(*) FROM users`) if err == nil { return qr.Count, nil } return -1, err
Is there a more idiomatic way to do this? Thanks.
The text was updated successfully, but these errors were encountered:
Check http://godoc.org/gopkg.in/pg.v3#example-LoadInto
var count int db.QueryOne(pg.LoadInto(&count), `SELECT COUNT(*) FROM users`)
Sorry, something went wrong.
No branches or pull requests
The db.Query and db.QueryOne expects a struct to populate. For a simple select count(*) query, what would you recommend?
My attempt:
Is there a more idiomatic way to do this? Thanks.
The text was updated successfully, but these errors were encountered: