Add storage func for getting a relation between two accounts

This commit is contained in:
Melody Becker 2024-11-15 16:14:11 +01:00
parent 5546d31e5d
commit 1f0dbda780

View file

@ -10,3 +10,16 @@ type AccountRelation struct {
ToId string ToId string
Accepted bool Accepted bool
} }
func (s *Storage) GetRelationBetween(fromId, toId string) (*AccountRelation, error) {
rel := AccountRelation{}
err := s.db.Where(AccountRelation{FromId: fromId, ToId: toId}).First(&rel).Error
switch err {
case gorm.ErrRecordNotFound:
return nil, ErrEntryNotFound
case nil:
return &rel, nil
default:
return nil, err
}
}