sqlboiler/cmds/templates/delete.tpl
Aaron 64ec06b4b4 Rename some functions.
- Use more efficient implementation of the template funcs.
2016-03-01 08:34:57 -08:00

14 lines
435 B
Smarty

{{- $tableName := .TableName -}}
// {{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
}