195e8d16e8
* Added bunch of new command names and descriptions. * Changed "all" command to "boil", so we can use "all" for the name of the all database select helper.
13 lines
508 B
Smarty
13 lines
508 B
Smarty
{{- $tableName := .TableName -}}
|
|
// {{makeGoColName $tableName}}All retrieves all records.
|
|
func {{makeGoColName $tableName}}All(db *sqlx.DB) ([]*{{makeGoColName $tableName}}, error) {
|
|
{{$varName := makeGoVarName $tableName -}}
|
|
var {{$varName}} []*{{makeGoColName $tableName}}
|
|
err := db.Select(&{{$varName}}, `SELECT {{makeSelectParamNames $tableName .TableData}}`)
|
|
|
|
if err != nil {
|
|
return nil, fmt.Errorf("models: unable to select from {{$tableName}}: %s", err)
|
|
}
|
|
|
|
return {{$varName}}, nil
|
|
}
|