repository

package
v0.0.0-...-433870c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUserNotFound is returned when a user was not found
	ErrUserNotFound = errors.New("user not found")
	// ErrUserAlreadyExists is returned when a user already exists
	ErrUserAlreadyExists = errors.New("user already exists")
	// ErrAlreadyExists is returned when an object already exists in the database
	ErrAlreadyExists = errors.New("object already exists")
	// ErrMandatoryDataMissing is returned when data is missing to execute a certain action
	ErrMandatoryDataMissing = errors.New("mandatory data is missing")
)

Functions

This section is empty.

Types

type AlertRepository

type AlertRepository interface {
	CreateAlert(alert models.Alert) (models.Alert, error)
	DeleteAlert(alert models.Alert) error
	GetAlertByToken(token string) (models.Alert, error)
	GetAlert(id uint) (models.Alert, error)
	UpdateAlertToken(alert models.Alert) (models.Alert, error)
	GetAlertReceiver(alert models.Alert) ([]models.User, error)
	GetSubscriberCount(alert models.Alert) (int64, error)

	GetUserAlerts(userID uint) ([]models.Alert, error)
	GetUserSubscribedAlerts(userID uint) ([]models.Alert, error)

	AddUserToAlert(alert models.Alert, user models.User) error
	RemoveUserFromAlert(alert models.Alert, user models.User) error
	SetMuteAlert(alert models.Alert, mute bool) error
}

AlertRepository defines Alert related data operations

type Configuration

type Configuration struct {
	ConnectionString   string `env:"CONNECTION_STRING"`
	MigrationDirectory string `env:"MIGRATION_DIR"`
}

Configuration stores the database configuration

type InviteRepository

type InviteRepository interface {
	CreateInvite(alert models.Alert) (models.Invite, error)
	GetInviteByToken(token string) (models.Invite, error)
	GetInvite(inviteID uint) (models.Invite, error)
	GetInviteByAlertID(alertID uint) (models.Invite, error)
	DeleteInvite(inviteID uint) error
}

InviteRepository defines invite related data operations

type Repository

type Repository interface {
	InitDatabase(config *Configuration) error
	MigrateDatabase() error

	AlertRepository
	InviteRepository
	UserRepository

	migration.VersionRepository
}

Repository interface

func NewPostgres

func NewPostgres(log *logrus.Logger) Repository

New Repository

type UserRepository

type UserRepository interface {
	CreateUser(user models.User) (models.User, error)
	GetUser(userID uint) (models.User, error)
	GetUserTelegram(telegramID int64) (models.User, error)
	DeleteUser(userID uint) error
}

UserRepository defines userdata operations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL