New issue
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
Named GET? #888
Comments
You can use Let me know if it works for you. |
@gab-aquino rows.Scan(&report.title, &report.description) Instead of rows.Scan(&report) This would make it cumbersome for larger structs. |
You can use |
Thnx for the tip, that would work: type DB struct {
*sqlx.DB
}
func (db DB) NamedGet(dest interface{}, query string, arg interface{}) error {
// Execute the named query
rows, err := db.NamedQuery(query, arg)
// Error check
if err != nil {
return err
}
// Scan into struct
if rows.Next() {
err = rows.StructScan(&dest)
}
// Error check
if err != nil {
return err
}
// Success
return nil
} |
How would I achieve the following, is there something like a NamedGET?
The text was updated successfully, but these errors were encountered: