diff --git a/storage/accountRelations.go b/storage/accountRelations.go index 644f44f..1a55eb9 100644 --- a/storage/accountRelations.go +++ b/storage/accountRelations.go @@ -10,3 +10,16 @@ type AccountRelation struct { ToId string 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 + } +}