sqlboiler/cmds/templates/selectwhere.tpl
Patrick O'brien 2f9c936c6a Added inflection library, fixed all templates
* Added inflection to all templates
* Fixed broken template code (for the most part)
2016-03-18 21:26:48 +10:00

12 lines
546 B
Smarty

{{- $tableNamePlural := titleCasePlural .Table -}}
// {{$tableNamePlural}}SelectWhere retrieves all records with the specified column values.
func {{$tableNamePlural}}SelectWhere(db boil.DB, results interface{}, columns map[string]interface{}) error {
query := fmt.Sprintf(`SELECT %s FROM {{.Table}} WHERE %s`, boil.SelectNames(results), boil.Where(columns))
err := db.Select(results, query, boil.WhereParams(columns)...)
if err != nil {
return fmt.Errorf("{{.PkgName}}: unable to select from {{.Table}}: %s", err)
}
return nil
}