2016-02-23 13:51:49 +01:00
|
|
|
{{- $tableName := .TableName -}}
|
2016-02-29 03:52:17 +01:00
|
|
|
// {{makeGoColName $tableName}}Delete deletes a single record.
|
|
|
|
func {{makeGoColName $tableName}}Delete(db *sqlx.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
|
|
|
|
}
|