More API progress
This time mainly helper functions for converting an account and associated types into their API representation
This commit is contained in:
parent
873f52d64f
commit
a653477e7f
8 changed files with 201 additions and 7 deletions
|
@ -20,3 +20,34 @@ type UserInfoField struct {
|
|||
}
|
||||
|
||||
// TODO: Add functions to store, load, update and delete these
|
||||
|
||||
func (s *Storage) FindUserFieldById(id uint) (*UserInfoField, error) {
|
||||
entry := UserInfoField{}
|
||||
err := s.db.First(&entry, id).Error
|
||||
switch err {
|
||||
case nil:
|
||||
return &entry, nil
|
||||
case gorm.ErrRecordNotFound:
|
||||
return nil, ErrEntryNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Storage) FindMultipleUserFieldsById(ids []uint) ([]UserInfoField, error) {
|
||||
entries := []UserInfoField{}
|
||||
err := s.db.Where(ids).Find(&entries).Error
|
||||
switch err {
|
||||
case gorm.ErrRecordNotFound:
|
||||
return nil, ErrEntryNotFound
|
||||
case nil:
|
||||
return entries, nil
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Storage) AddNewUserField(name, value, belongsToId string) (*UserInfoField, error) {
|
||||
// TODO: Implement me
|
||||
panic("Not implemented")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue