sqlboiler/cmds/templates/delete.tpl

15 lines
445 B
Smarty
Raw Normal View History

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