1
0

implemented binding url params directly to struct instead of passing them to the method for deleting items

This commit is contained in:
konrad
2018-07-18 08:15:38 +02:00
committed by kolaente
parent f0c003d069
commit 249128a46e
17 changed files with 48 additions and 40 deletions

View File

@ -1,22 +1,22 @@
package models
// Delete deletes a namespace
func (n *Namespace) Delete(id int64) (err error) {
func (n *Namespace) Delete() (err error) {
// Check if the namespace exists
_, err = GetNamespaceByID(id)
_, err = GetNamespaceByID(n.ID)
if err != nil {
return
}
// Delete the namespace
_, err = x.ID(id).Delete(&Namespace{})
_, err = x.ID(n.ID).Delete(&Namespace{})
if err != nil {
return
}
// Delete all lists with their items
lists, err := GetListsByNamespaceID(id)
lists, err := GetListsByNamespaceID(n.ID)
var listIDs []int64
// We need to do that for here because we need the list ids to delete two times:
// 1) to delete the lists itself