sqlboiler/cmds/templates/delete.tpl

14 lines
431 B
Smarty

{{- $tableName := .Table -}}
// {{titleCase $tableName}}Delete deletes a single record.
func {{titleCase $tableName}}Delete(db boil.DB, id int) error {
if id == nil {
return nil, errors.New("model: no id provided for {{$tableName}} delete")
}
err := db.Exec("DELETE FROM {{$tableName}} WHERE id=$1", id)
if err != nil {
return errors.New("model: unable to delete from {{$tableName}}: %s", err)
}
return nil
}