vegapokerbot/internal/db/repository/chat.go

32 lines
706 B
Go
Raw Normal View History

2024-05-07 21:49:09 +03:00
package repository
import (
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/db/model"
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/db/util"
"gorm.io/gorm"
)
type Chat struct {
db *gorm.DB
}
func NewChat(db *gorm.DB) *Chat {
return &Chat{db: db}
}
func (c *Chat) ByID(id uint64) (*model.Chat, error) {
var chat *model.Chat
if err := c.db.First(&chat, id).Error; err != nil {
return nil, util.HandleRecordNotFound(err)
}
return chat, nil
}
func (c *Chat) ByIDWithIntegrations(id uint64) (*model.Chat, error) {
var chat *model.Chat
if err := c.db.Preload("Integrations").First(&chat, id).Error; err != nil {
return nil, util.HandleRecordNotFound(err)
}
return chat, nil
}