From cea3009641dd1a7b914fdd5dcae1a8367a28d5ac Mon Sep 17 00:00:00 2001 From: mStar Date: Thu, 7 Nov 2024 10:47:09 +0100 Subject: [PATCH] Implement custom account field deletion Custom account fields can now be deleted either one at a time via id or all fields owned by an account --- storage/userInfoFields.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/storage/userInfoFields.go b/storage/userInfoFields.go index 4eed6ec..5bc349a 100644 --- a/storage/userInfoFields.go +++ b/storage/userInfoFields.go @@ -55,3 +55,16 @@ func (s *Storage) AddNewUserField(name, value, belongsToId string) (*UserInfoFie // TODO: Implement me panic("Not implemented") } + +func (s *Storage) DeleteUserField(id uint) error { + defer util.Untrace(util.Trace(&log.Logger)) + return s.db.Delete(UserInfoField{Model: gorm.Model{ID: id}}).Error +} + +func (s *Storage) DeleteAllUserFieldsForAccountId(id string) error { + defer util.Untrace(util.Trace(&log.Logger)) + return s.db.Model(&UserInfoField{}). + Where(&UserInfoField{BelongsTo: id}). + Delete(&UserInfoField{}). + Error +}