2016-02-23 13:51:49 +01:00
|
|
|
{{- $tableName := .TableName -}}
|
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-02-29 03:52:17 +01:00
|
|
|
return nil, errors.New("model: 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-02-29 03:52:17 +01:00
|
|
|
return errors.New("model: unable to delete from {{$tableName}}: %s", err)
|
2016-02-23 13:51:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|