2f9c936c6a
* Added inflection to all templates * Fixed broken template code (for the most part)
16 lines
777 B
Smarty
16 lines
777 B
Smarty
{{- $tableNameSingular := titleCaseSingular .Table -}}
|
|
{{- $dbName := singular .Table -}}
|
|
{{- $tableNamePlural := titleCasePlural .Table -}}
|
|
{{- $varNamePlural := camelCasePlural .Table -}}
|
|
// {{$tableNamePlural}}Where retrieves all records with the specified column values.
|
|
func {{$tableNamePlural}}Where(db boil.DB, columns map[string]interface{}) ([]*{{$tableNameSingular}}, error) {
|
|
var {{$varNamePlural}} []*{{$tableNameSingular}}
|
|
query := fmt.Sprintf(`SELECT {{selectParamNames $dbName .Columns}} FROM {{.Table}} WHERE %s`, boil.Where(columns))
|
|
err := db.Select(&{{$varNamePlural}}, query, boil.WhereParams(columns)...)
|
|
|
|
if err != nil {
|
|
return nil, fmt.Errorf("{{.PkgName}}: unable to select from {{.Table}}: %s", err)
|
|
}
|
|
|
|
return {{$varNamePlural}}, nil
|
|
}
|