2016-02-29 12:45:28 +01:00
|
|
|
{{- $tableName := .TableName -}}
|
2016-03-01 17:34:57 +01:00
|
|
|
// {{titleCase $tableName}}FieldsAll retrieves the specified columns for all records.
|
2016-02-29 12:45:28 +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-01 17:34:57 +01:00
|
|
|
func {{titleCase $tableName}}FieldsAll(db boil.DB, results interface{}) error {
|
|
|
|
{{$varName := camelCase $tableName -}}
|
|
|
|
var {{$varName}} []*{{titleCase $tableName}}
|
|
|
|
err := db.Select(&{{$varName}}, `SELECT {{selectParamNames $tableName .TableData}}`)
|
2016-02-29 12:45:28 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("models: unable to select from {{$tableName}}: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return {{$varName}}, nil
|
|
|
|
}
|