sqlboiler/cmds/templates/selectwhere.tpl

13 lines
561 B
Smarty
Raw Normal View History

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