Added method to delete a list
This commit is contained in:
parent
853fb2a2b7
commit
dcb046665f
4 changed files with 49 additions and 0 deletions
21
models/list_delete.go
Normal file
21
models/list_delete.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package models
|
||||
|
||||
func DeleteListByID(listID int64) (err error) {
|
||||
|
||||
// Check if the list exists
|
||||
_, err = GetListByID(listID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Delete the list
|
||||
_, err = x.ID(listID).Delete(&List{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Delete all todoitems on that list
|
||||
_, err = x.Where("list_id = ?", listID).Delete(&ListItem{})
|
||||
|
||||
return
|
||||
}
|
||||
Reference in a new issue