implemented binding url params directly to struct instead of passing them to the method for deleting items
This commit is contained in:
@ -1,20 +1,20 @@
|
||||
package models
|
||||
|
||||
// Delete implements the delete method of CRUDable
|
||||
func (l *List) Delete(id int64) (err error) {
|
||||
func (l *List) Delete() (err error) {
|
||||
// Check if the list exists
|
||||
_, err = GetListByID(id)
|
||||
_, err = GetListByID(l.ID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Delete the list
|
||||
_, err = x.ID(id).Delete(&List{})
|
||||
_, err = x.ID(l.ID).Delete(&List{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Delete all todoitems on that list
|
||||
_, err = x.Where("list_id = ?", id).Delete(&ListItem{})
|
||||
_, err = x.Where("list_id = ?", l.ID).Delete(&ListItem{})
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user