mirror-nourybot/internal/data/models.go
2022-08-09 21:25:44 +02:00

33 lines
640 B
Go

package data
import (
"database/sql"
"errors"
)
var (
ErrRecordNotFound = errors.New("record not found")
ErrRecordAlreadyExists = errors.New("channel already in database")
)
// struct Models wraps the models, making them callable
// as app.models.Channels.Get(login)
type Models struct {
Channels interface {
Insert(channel *Channel) error
Get(login string) (*Channel, error)
Delete(login string) error
}
User interface {
Insert(channel *Channel) error
Get(login string) (*Channel, error)
Delete(login string) error
}
}
func NewModels(db *sql.DB) Models {
return Models{
Channels: ChannelModel{DB: db},
}
}