You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
synctv/internal/db/relation.go

18 lines
478 B
Go

package db
import (
"errors"
"github.com/synctv-org/synctv/internal/model"
"gorm.io/gorm"
)
func GetRoomUserRelation(roomID, userID uint) (*model.RoomUserRelation, error) {
roomUserRelation := &model.RoomUserRelation{}
err := db.Where("room_id = ? AND user_id = ?", roomID, userID).First(roomUserRelation).Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
return roomUserRelation, errors.New("room or user not found")
}
return roomUserRelation, err
}