package store import "github.com/google/uuid" type UserHost struct { ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"` Email string `gorm:"unique;size:255" json:"email"` Host string `gorm:"size:255" json:"host"` } func (UserHost) TableName() string { return "user_hosts" } // GetUserHost returns the host associated with the given email func (s *DataStore) GetUserHost(email string) (string, error) { var user UserHost if err := s.db.Where("email = ?", email).First(&user).Error; err != nil { return "", err } return user.Host, nil } // AddUserHost adds a new user with the given email and host func (s *DataStore) AddUserHost(email, host string) error { user := UserHost{ Email: email, Host: host, } return s.db.Create(&user).Error } // DeleteUserHost deletes the user with the given email func (s *DataStore) DeleteUserHost(email string) error { return s.db.Where("email = ?", email).Delete(UserHost{}).Error } // UpdateUserHost updates the host associated with the given email func (s *DataStore) UpdateUserHost(email, host string) error { return s.db.Model(UserHost{}).Where("email = ?", email).Update("host", host).Error }