2016-03-23 07:18:41 +01:00
|
|
|
{{- $tableNamePlural := titleCasePlural .Table.Name -}}
|
2016-03-18 12:26:48 +01:00
|
|
|
// {{$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))
|
2016-03-16 15:33:58 +01:00
|
|
|
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)
|
2016-03-16 15:33:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|