sqlboiler/templates/delete.tpl

14 lines
381 B
Smarty
Raw Normal View History

2016-02-23 13:51:49 +01:00
{{- $tableName := .TableName -}}
func Delete{{makeGoColName $tableName}}(id int, db *sqlx.DB) error {
if id == nil {
return nil, errors.New("No ID provided for {{makeGoColName $tableName}} delete")
}
err := db.Exec("DELETE FROM {{$tableName}} WHERE id=$1", id)
if err != nil {
return errors.New("Unable to delete from {{$tableName}}: %s", err)
}
return nil
}