2016-03-18 12:26:48 +01:00
|
|
|
{{- $tableNamePlural := titleCasePlural .Table -}}
|
|
|
|
// {{$tableNamePlural}}Select retrieves the specified columns for all records.
|
2016-03-16 15:33:58 +01:00
|
|
|
// Pass in a pointer to an object with `db` tags that match the column names you wish to retrieve.
|
|
|
|
// For example: friendName string `db:"friend_name"`
|
2016-03-18 12:26:48 +01:00
|
|
|
func {{$tableNamePlural}}Select(db boil.DB, results interface{}) error {
|
|
|
|
query := fmt.Sprintf(`SELECT %s FROM {{.Table}}`, boil.SelectNames(results))
|
2016-03-16 15:33:58 +01:00
|
|
|
err := db.Select(results, query)
|
|
|
|
|
|
|
|
if err != nil {
|
2016-03-18 12:26:48 +01:00
|
|
|
return fmt.Errorf("{{.PkgName}}: unable to select from {{.Table}}: %s", err)
|
2016-03-16 15:33:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|