add new relational table requests

This commit is contained in:
Adrian Zürcher
2025-11-27 07:58:43 +01:00
parent f28a3edbcf
commit b0895aee01
11 changed files with 125 additions and 166 deletions

View File

@@ -11,7 +11,7 @@ func (dh *DatabaseHandler) NewGroup(group *models.Group) error {
return errors.New("database not opened")
}
if dh.database.Exists(&models.Group{}, "", "name", group.Name, false) {
if dh.database.Exists(&models.Group{}, "name", group.Name, false) {
return errors.New("group with name: " + group.Name + " exists already")
}
return dh.database.AddNewColum(&group)
@@ -22,18 +22,18 @@ func (dh *DatabaseHandler) GetGroup(id uint) (group []models.Group, err error) {
return group, errors.New("database not opened")
}
err = dh.database.GetById(&group, "", id)
err = dh.database.GetById(&group, id)
if err != nil {
return
}
return
}
func (dh *DatabaseHandler) UpdateGroup(id int, group models.Group) (err error) {
func (dh *DatabaseHandler) UpdateGroup(id uint, group models.Group) (err error) {
if !dh.DatabaseOpened() {
return errors.New("database not opened")
}
return dh.database.UpdateValuesById(&group, "", uint(group.Id))
return dh.database.UpdateValuesById(&group, uint(group.Id))
}
func (dh *DatabaseHandler) DeleteGroup(ids ...uint) error {