2016-03-02 05:05:25 +01:00
|
|
|
{{- $tableName := .Table -}}
|
2016-03-01 17:34:57 +01:00
|
|
|
// {{titleCase $tableName}}Delete deletes a single record.
|
|
|
|
func {{titleCase $tableName}}Delete(db boil.DB, id int) error {
|
2016-02-23 13:51:49 +01:00
|
|
|
if id == nil {
|
2016-03-16 15:33:58 +01:00
|
|
|
return nil, errors.New("{{.PkgName}}: no id provided for {{$tableName}} delete")
|
2016-02-23 13:51:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
err := db.Exec("DELETE FROM {{$tableName}} WHERE id=$1", id)
|
|
|
|
if err != nil {
|
2016-03-16 15:33:58 +01:00
|
|
|
return errors.New("{{.PkgName}}: unable to delete from {{$tableName}}: %s", err)
|
2016-02-23 13:51:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|