db

package
v0.0.0-...-16d05a1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDBManagerInstance

func GetDBManagerInstance() *dbManager

Types

type AdminDB

type AdminDB[T models.Admin] struct {
	// contains filtered or unexported fields
}

func NewAdminDB

func NewAdminDB(db *gorm.DB) *AdminDB[models.Admin]

func (*AdminDB[T]) Add

func (a *AdminDB[T]) Add(admin *models.Admin) error

func (*AdminDB[T]) AddMany

func (a *AdminDB[T]) AddMany(admins []*models.Admin) error

func (*AdminDB[T]) Count

func (a *AdminDB[T]) Count() (int64, error)

func (*AdminDB[T]) Delete

func (a *AdminDB[T]) Delete(admin models.Admin, conds ...any) error

func (*AdminDB[T]) DeleteAll

func (a *AdminDB[T]) DeleteAll(conds ...any) error

func (*AdminDB[T]) Exists

func (a *AdminDB[T]) Exists(id uint) bool

func (*AdminDB[T]) Get

func (a *AdminDB[T]) Get(id uint) (fetchedAdmin models.Admin, err error)

func (*AdminDB[T]) GetAll

func (a *AdminDB[T]) GetAll() ([]models.Admin, error)

func (*AdminDB[T]) GetByConds

func (a *AdminDB[T]) GetByConds(conds ...any) ([]models.Admin, error)

func (*AdminDB[T]) GetDB

func (a *AdminDB[T]) GetDB() *gorm.DB

func (*AdminDB[T]) Update

func (a *AdminDB[T]) Update(admin *models.Admin, conds ...any) error

func (*AdminDB[T]) UpdateAll

func (a *AdminDB[T]) UpdateAll(admins []*models.Admin, conds ...any) error

type ContestDB

type ContestDB[T models.Contest, T2 any] struct {
	// contains filtered or unexported fields
}

ContestDB represents a CRUD db repo for contests

func NewContestDB

func NewContestDB(db *gorm.DB, teamRepo data.Many2ManyCRUDRepo[models.Team, any]) *ContestDB[models.Contest, any]

NewContestDB returns a new ContestDB instance

func (*ContestDB[T, T2]) Add

func (c *ContestDB[T, T2]) Add(contest *models.Contest) error

func (*ContestDB[T, T2]) AddMany

func (c *ContestDB[T, T2]) AddMany(contests []*models.Contest) error

func (*ContestDB[T, T2]) Count

func (c *ContestDB[T, T2]) Count() (int64, error)

func (*ContestDB[T, T2]) Delete

func (c *ContestDB[T, T2]) Delete(contest models.Contest, conds ...any) error

func (*ContestDB[T, T2]) DeleteAll

func (c *ContestDB[T, T2]) DeleteAll(conds ...any) error

func (*ContestDB[T, T2]) Exists

func (c *ContestDB[T, T2]) Exists(id uint) bool

func (*ContestDB[T, T2]) Get

func (c *ContestDB[T, T2]) Get(id uint) (fetchedContest models.Contest, err error)

func (*ContestDB[T, T2]) GetAll

func (c *ContestDB[T, T2]) GetAll() (contests []models.Contest, err error)

func (*ContestDB[T, T2]) GetByAssociation

func (c *ContestDB[T, T2]) GetByAssociation(org any) (contests []models.Contest, err error)

func (*ContestDB[T, T2]) GetByConds

func (c *ContestDB[T, T2]) GetByConds(conds ...any) ([]models.Contest, error)

func (*ContestDB[T, T2]) GetDB

func (c *ContestDB[T, T2]) GetDB() *gorm.DB

func (*ContestDB[T, T2]) Update

func (c *ContestDB[T, T2]) Update(contest *models.Contest, conds ...any) error

func (*ContestDB[T, T2]) UpdateAll

func (c *ContestDB[T, T2]) UpdateAll(contests []*models.Contest, conds ...any) error

type ContestantDB

type ContestantDB[T models.Contestant] struct {
	// contains filtered or unexported fields
}

ContestantDB represents a CRUD db repo for contestants

func NewContestantDB

func NewContestantDB(db *gorm.DB) *ContestantDB[models.Contestant]

NewContestantDB returns a new ContestantDB instance

func (*ContestantDB[T]) Add

func (c *ContestantDB[T]) Add(contestant *models.Contestant) error

func (*ContestantDB[T]) AddMany

func (c *ContestantDB[T]) AddMany(conts []*models.Contestant) error

func (*ContestantDB[T]) Count

func (c *ContestantDB[T]) Count() (int64, error)

func (*ContestantDB[T]) Delete

func (c *ContestantDB[T]) Delete(contestant models.Contestant, conds ...any) error

func (*ContestantDB[T]) DeleteAll

func (c *ContestantDB[T]) DeleteAll(conds ...any) error

func (*ContestantDB[T]) Exists

func (c *ContestantDB[T]) Exists(userID uint) bool

func (*ContestantDB[T]) Get

func (c *ContestantDB[T]) Get(userID uint) (fetchedContestant models.Contestant, err error)

func (*ContestantDB[T]) GetAll

func (c *ContestantDB[T]) GetAll() ([]models.Contestant, error)

func (*ContestantDB[T]) GetByConds

func (c *ContestantDB[T]) GetByConds(conds ...any) ([]models.Contestant, error)

func (*ContestantDB[T]) GetDB

func (c *ContestantDB[T]) GetDB() *gorm.DB

func (*ContestantDB[T]) Update

func (c *ContestantDB[T]) Update(cont *models.Contestant, conds ...any) error

func (*ContestantDB[T]) UpdateAll

func (c *ContestantDB[T]) UpdateAll(conts []*models.Contestant, conds ...any) error

type JoinRequestDB

type JoinRequestDB[T models.JoinRequest] struct {
	// contains filtered or unexported fields
}

JoinRequestDB represents a CRUD db repo for jrs

func NewJoinRequestDB

func NewJoinRequestDB(db *gorm.DB) *JoinRequestDB[models.JoinRequest]

NewJoinRequestDB returns a new JoinRequestDB instance

func (*JoinRequestDB[T]) Add

func (j *JoinRequestDB[T]) Add(jr *models.JoinRequest) error

func (*JoinRequestDB[T]) AddMany

func (j *JoinRequestDB[T]) AddMany(jr []*models.JoinRequest) error

func (*JoinRequestDB[T]) Count

func (j *JoinRequestDB[T]) Count() (count int64, err error)

func (*JoinRequestDB[T]) Delete

func (j *JoinRequestDB[T]) Delete(jr models.JoinRequest, conds ...any) error

func (*JoinRequestDB[T]) DeleteAll

func (j *JoinRequestDB[T]) DeleteAll(conds ...any) error

func (*JoinRequestDB[T]) Exists

func (j *JoinRequestDB[T]) Exists(id uint) bool

func (*JoinRequestDB[T]) Get

func (j *JoinRequestDB[T]) Get(id uint) (jr models.JoinRequest, err error)

func (*JoinRequestDB[T]) GetAll

func (j *JoinRequestDB[T]) GetAll() (jr []models.JoinRequest, err error)

func (*JoinRequestDB[T]) GetByConds

func (j *JoinRequestDB[T]) GetByConds(conds ...any) (jrs []models.JoinRequest, err error)

func (*JoinRequestDB[T]) GetDB

func (j *JoinRequestDB[T]) GetDB() *gorm.DB

func (*JoinRequestDB[T]) Update

func (j *JoinRequestDB[T]) Update(jr *models.JoinRequest, conds ...any) error

func (*JoinRequestDB[T]) UpdateAll

func (j *JoinRequestDB[T]) UpdateAll(jrs []*models.JoinRequest, conds ...any) error

type NotificationDB

type NotificationDB[T models.Notification] struct {
	// contains filtered or unexported fields
}

NotificationDB represents a CRUD db repo for notifications

func NewNotificationDB

func NewNotificationDB(db *gorm.DB) *NotificationDB[models.Notification]

NewNotificationDB returns a new NotificationDB instance

func (*NotificationDB[T]) Add

func (n *NotificationDB[T]) Add(notification *models.Notification) error

func (*NotificationDB[T]) AddMany

func (n *NotificationDB[T]) AddMany(notifications []*models.Notification) error

func (*NotificationDB[T]) Count

func (n *NotificationDB[T]) Count() (int64, error)

func (*NotificationDB[T]) Delete

func (n *NotificationDB[T]) Delete(notification models.Notification, conds ...any) error

func (*NotificationDB[T]) DeleteAll

func (n *NotificationDB[T]) DeleteAll(conds ...any) error

func (*NotificationDB[T]) Exists

func (n *NotificationDB[T]) Exists(nID uint) bool

func (*NotificationDB[T]) Get

func (n *NotificationDB[T]) Get(nID uint) (notification models.Notification, err error)

func (*NotificationDB[T]) GetAll

func (n *NotificationDB[T]) GetAll() ([]models.Notification, error)

func (*NotificationDB[T]) GetByConds

func (n *NotificationDB[T]) GetByConds(conds ...any) (notifications []models.Notification, err error)

func (*NotificationDB[T]) GetDB

func (n *NotificationDB[T]) GetDB() *gorm.DB

func (*NotificationDB[T]) Update

func (n *NotificationDB[T]) Update(notification *models.Notification, conds ...any) error

func (*NotificationDB[T]) UpdateAll

func (n *NotificationDB[T]) UpdateAll(notifications []*models.Notification, conds ...any) error

type OrganizeContestDB

type OrganizeContestDB struct {
	// contains filtered or unexported fields
}

func NewOrganizeOrganizeContestDB

func NewOrganizeOrganizeContestDB(db *gorm.DB) *OrganizeContestDB

func (*OrganizeContestDB) Add

func (*OrganizeContestDB) Count

func (c *OrganizeContestDB) Count() (int64, error)

func (*OrganizeContestDB) Delete

func (*OrganizeContestDB) DeleteAll

func (c *OrganizeContestDB) DeleteAll() error

func (*OrganizeContestDB) Exists

func (*OrganizeContestDB) Get

func (*OrganizeContestDB) GetContests

func (c *OrganizeContestDB) GetContests(org models.Organizer) (contests []models.Contest, err error)

func (*OrganizeContestDB) GetOrgs

func (c *OrganizeContestDB) GetOrgs(contest models.Contest) (orgs []models.Organizer, err error)

func (*OrganizeContestDB) Update

type OrganizerDB

type OrganizerDB[T models.Organizer] struct {
	// contains filtered or unexported fields
}

OrganizerDB represents a CRUD db repo for organizers

func NewOrganizerDB

func NewOrganizerDB(db *gorm.DB) *OrganizerDB[models.Organizer]

NewOrganizerDB returns a new OrganizerDB instance

func (*OrganizerDB[T]) Add

func (o *OrganizerDB[T]) Add(organizer *models.Organizer) error

func (*OrganizerDB[T]) AddMany

func (o *OrganizerDB[T]) AddMany(orgs []*models.Organizer) error

func (*OrganizerDB[T]) Count

func (o *OrganizerDB[T]) Count() (int64, error)

func (*OrganizerDB[T]) Delete

func (o *OrganizerDB[T]) Delete(organizer models.Organizer, conds ...any) error

func (*OrganizerDB[T]) DeleteAll

func (o *OrganizerDB[T]) DeleteAll(conds ...any) error

func (*OrganizerDB[T]) Exists

func (o *OrganizerDB[T]) Exists(userID uint) bool

func (*OrganizerDB[T]) Get

func (o *OrganizerDB[T]) Get(userID uint) (fetchedOrganizer models.Organizer, err error)

func (*OrganizerDB[T]) GetAll

func (o *OrganizerDB[T]) GetAll() ([]models.Organizer, error)

func (*OrganizerDB[T]) GetByConds

func (o *OrganizerDB[T]) GetByConds(conds ...any) ([]models.Organizer, error)

func (*OrganizerDB[T]) GetDB

func (o *OrganizerDB[T]) GetDB() *gorm.DB

func (*OrganizerDB[T]) Update

func (o *OrganizerDB[T]) Update(organizer *models.Organizer, conds ...any) error

func (*OrganizerDB[T]) UpdateAll

func (o *OrganizerDB[T]) UpdateAll(orgs []*models.Organizer, conds ...any) error

type SessionDB

type SessionDB[T models.Session] struct {
	// contains filtered or unexported fields
}

SessionDB represents a CRUD db repo for sessions

func NewSessionDB

func NewSessionDB[T models.Session](db *gorm.DB) *SessionDB[T]

NewSessionDB returns a new SessionDB instance

func (*SessionDB[T]) Add

func (s *SessionDB[T]) Add(session *models.Session) error

func (*SessionDB[T]) AddMany

func (s *SessionDB[T]) AddMany(sessions []*models.Session) error

func (*SessionDB[T]) Count

func (s *SessionDB[T]) Count() (int64, error)

func (*SessionDB[T]) Delete

func (s *SessionDB[T]) Delete(session models.Session, conds ...any) error

func (*SessionDB[T]) DeleteAll

func (s *SessionDB[T]) DeleteAll(conds ...any) error

func (*SessionDB[T]) Exists

func (s *SessionDB[T]) Exists(id uint) bool

func (*SessionDB[T]) Get

func (s *SessionDB[T]) Get(id uint) (models.Session, error)

func (*SessionDB[T]) GetAll

func (s *SessionDB[T]) GetAll() ([]models.Session, error)

func (*SessionDB[T]) GetByConds

func (s *SessionDB[T]) GetByConds(conds ...any) (sessions []models.Session, err error)

func (*SessionDB[T]) GetDB

func (s *SessionDB[T]) GetDB() *gorm.DB

func (*SessionDB[T]) Update

func (s *SessionDB[T]) Update(session *models.Session, conds ...any) error

func (*SessionDB[T]) UpdateAll

func (s *SessionDB[T]) UpdateAll(sessions []*models.Session, conds ...any) error

type TeamDB

type TeamDB[T models.Team, T2 any] struct {
	// contains filtered or unexported fields
}

TeamDB represents a CRUD db repo for teams

func NewTeamDB

func NewTeamDB(db *gorm.DB) *TeamDB[models.Team, any]

NewTeamDB returns a new TeamDB instance

func (*TeamDB[T, T2]) Add

func (t *TeamDB[T, T2]) Add(team *models.Team) error

func (*TeamDB[T, T2]) AddMany

func (t *TeamDB[T, T2]) AddMany(teams []*models.Team) error

AddMany creates multiple teams, this method is only used when a contest's director generates teams for the teamless contestants.

func (*TeamDB[T, T2]) Count

func (t *TeamDB[T, T2]) Count() (int64, error)

func (*TeamDB[T, T2]) Delete

func (t *TeamDB[T, T2]) Delete(team models.Team, conds ...any) error

func (*TeamDB[T, T2]) DeleteAll

func (t *TeamDB[T, T2]) DeleteAll(conds ...any) error

func (*TeamDB[T, T2]) Exists

func (t *TeamDB[T, T2]) Exists(id uint) bool

func (*TeamDB[T, T2]) Get

func (t *TeamDB[T, T2]) Get(id uint) (fetchedTeam models.Team, err error)

func (*TeamDB[T, T2]) GetAll

func (t *TeamDB[T, T2]) GetAll() (teams []models.Team, err error)

func (*TeamDB[T, T2]) GetByAssociation

func (t *TeamDB[T, T2]) GetByAssociation(contest any) ([]models.Team, error)

func (*TeamDB[T, T2]) GetByConds

func (t *TeamDB[T, T2]) GetByConds(conds ...any) (teams []models.Team, err error)

func (*TeamDB[T, T2]) GetDB

func (t *TeamDB[T, T2]) GetDB() *gorm.DB

func (*TeamDB[T, T2]) Update

func (t *TeamDB[T, T2]) Update(team *models.Team, conds ...any) error

func (*TeamDB[T, T2]) UpdateAll

func (t *TeamDB[T, T2]) UpdateAll(teams []*models.Team, conds ...any) error

type UserDB

type UserDB[T models.User] struct {
	// contains filtered or unexported fields
}

func NewUserDB

func NewUserDB(db *gorm.DB) *UserDB[models.User]

func (*UserDB[T]) Add

func (u *UserDB[T]) Add(user *models.User) error

func (*UserDB[T]) AddMany

func (u *UserDB[T]) AddMany(users []*models.User) error

func (*UserDB[T]) Count

func (u *UserDB[T]) Count() (count int64, err error)

func (*UserDB[T]) Delete

func (u *UserDB[T]) Delete(user models.User, conds ...any) error

func (*UserDB[T]) DeleteAll

func (u *UserDB[T]) DeleteAll(conds ...any) error

func (*UserDB[T]) Exists

func (u *UserDB[T]) Exists(userID uint) bool

func (*UserDB[T]) Get

func (u *UserDB[T]) Get(userID uint) (fetchedUser models.User, err error)

func (*UserDB[T]) GetAll

func (u *UserDB[T]) GetAll() (users []models.User, err error)

func (*UserDB[T]) GetByConds

func (u *UserDB[T]) GetByConds(conds ...any) (users []models.User, err error)

func (*UserDB[T]) GetDB

func (u *UserDB[T]) GetDB() *gorm.DB

func (*UserDB[T]) Update

func (u *UserDB[T]) Update(user *models.User, conds ...any) (err error)

func (*UserDB[T]) UpdateAll

func (u *UserDB[T]) UpdateAll(users []*models.User, conds ...any) error

Jump to

Keyboard shortcuts

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