Documentation ¶
Index ¶
- Variables
- func Exists(userID, friendID string, db *gorm.DB) bool
- func GetIDsByUserID(userID string, db *gorm.DB) (uuids []string, err error)
- func ListConfirmedIDsByUserID(userID string, db *gorm.DB) (uuids []string, err error)
- func TestValidation(t *testing.T)
- type CreatorBinding
- type Friendship
- type Friendships
- type UpdaterBinding
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrFriendSelf = errors.New("You cannot friend yourself. Being friends with yourself is weird. Go be friends with other people.")
)
Functions ¶
func TestValidation ¶
Types ¶
type CreatorBinding ¶
type CreatorBinding struct {
FriendID string `json:"friend_id" binding:"required"`
}
type Friendship ¶
type Friendship struct { ID string `json:"id" gorm:"primary_key" sql:"type:uuid;default:uuid_generate_v4()"` UserID string `json:"user_id" sql:"type:uuid"` // ID of first user FriendID string `json:"friend_id" sql:"type:uuid"` // ID of second user Friend users.User `json:"user" sql:"-"` Match float64 `json:"match" sql:"-"` Confirmed bool `json:"confirmed"` // Whether the second user has confirmed CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Friendship is a joining table between two users who are friends. For each friendship there are two Friendship records: one for each user
func GetByUserIDs ¶
func GetByUserIDs(userID, friendID string, db *gorm.DB) (f Friendship, err error)
func New ¶
func New(userID string, b CreatorBinding) (f Friendship, errs models.ValidationErrors)
func (Friendship) CanDelete ¶
func (f Friendship) CanDelete(userID string) bool
func (Friendship) GetAction ¶
func (f Friendship) GetAction() string
func (Friendship) GetID ¶
func (f Friendship) GetID() string
func (Friendship) GetNotifType ¶
func (f Friendship) GetNotifType() string
func (*Friendship) Update ¶
func (f *Friendship) Update(b UpdaterBinding) models.ValidationErrors
func (Friendship) Validate ¶
func (f Friendship) Validate() (errs models.ValidationErrors)
type Friendships ¶
type Friendships []Friendship
func GetConfirmedByUserID ¶
func GetConfirmedByUserID(userID string, db *gorm.DB) (fs Friendships, err error)
func ListByUserID ¶
func ListByUserID(userID string, db *gorm.DB) (fs Friendships, err error)
func ListConfirmedByUserID ¶
func ListConfirmedByUserID(userID string, db *gorm.DB) (fs Friendships, err error)
type UpdaterBinding ¶
type UpdaterBinding struct {
Confirmed bool `json:"confirmed" binding:"required"`
}
Click to show internal directories.
Click to hide internal directories.