database

package
v0.0.0-...-eefbc77 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: GPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Model returns the repository containing all model operations.
	Model() *Repository
	// Service returns the service containing all service operations.
	Service() *Service
	// Close gracefully shuts down the database connection.
	Close() error
	// DB returns the underlying bun.DB instance.
	DB() *bun.DB
}

Client defines the methods that a database client must implement.

func NewConnection

func NewConnection(
	ctx context.Context, config *config.PostgreSQL, logger *zap.Logger, autoMigrate bool,
) (Client, error)

NewConnection establishes a new database connection and returns a Client instance.

type Hook

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

Hook implements bun.QueryHook interface for logging queries with zap.

func NewHook

func NewHook(logger *zap.Logger) *Hook

NewHook creates a new Hook with zap logger.

func (*Hook) AfterQuery

func (h *Hook) AfterQuery(_ context.Context, event *bun.QueryEvent)

AfterQuery logs the query and its execution time.

func (*Hook) BeforeQuery

func (h *Hook) BeforeQuery(ctx context.Context, _ *bun.QueryEvent) context.Context

BeforeQuery logs the query before execution.

type Repository

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

Repository provides access to all database models.

func NewRepository

func NewRepository(db *bun.DB, logger *zap.Logger) *Repository

NewRepository creates a new repository instance with all models.

func (*Repository) Activity

func (r *Repository) Activity() *models.ActivityModel

Activity returns the activities model repository.

func (*Repository) Cache

func (r *Repository) Cache() *models.CacheModel

Cache returns the cache model repository.

func (*Repository) Comment

func (r *Repository) Comment() *models.CommentModel

Comment returns the comment model repository.

func (*Repository) Consent

func (r *Repository) Consent() *models.ConsentModel

Consent returns the consent model repository.

func (*Repository) Group

func (r *Repository) Group() *models.GroupModel

Group returns the group model repository.

func (*Repository) GuildBan

func (r *Repository) GuildBan() *models.GuildBanModel

GuildBan returns the guild ban model repository.

func (*Repository) Message

func (r *Repository) Message() *models.MessageModel

Message returns the message model repository.

func (*Repository) Reviewer

func (r *Repository) Reviewer() *models.ReviewerModel

Reviewer returns the reviewer model repository.

func (*Repository) Setting

func (r *Repository) Setting() *models.SettingModel

Setting returns the setting model repository.

func (*Repository) Stats

func (r *Repository) Stats() *models.StatsModel

Stats returns the stats model repository.

func (*Repository) Sync

func (r *Repository) Sync() *models.SyncModel

Sync returns the sync model repository.

func (*Repository) Tracking

func (r *Repository) Tracking() *models.TrackingModel

Tracking returns the tracking model repository.

func (*Repository) User

func (r *Repository) User() *models.UserModel

User returns the user model repository.

func (*Repository) View

View returns the materialized view model repository.

type Service

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

Service provides access to all business logic services.

func NewService

func NewService(db *bun.DB, repository *Repository, logger *zap.Logger) *Service

NewService creates a new service instance with all services.

func (*Service) Cache

func (s *Service) Cache() *service.CacheService

Cache returns the cache service.

func (*Service) Comment

func (s *Service) Comment() *service.CommentService

Comment returns the comment service.

func (*Service) Group

func (s *Service) Group() *service.GroupService

Group returns the group service.

func (*Service) Reviewer

func (s *Service) Reviewer() *service.ReviewerService

Reviewer returns the reviewer service.

func (*Service) Stats

func (s *Service) Stats() *service.StatsService

Stats returns the stats service.

func (*Service) Sync

func (s *Service) Sync() *service.SyncService

Sync returns the sync service.

func (*Service) User

func (s *Service) User() *service.UserService

User returns the user service.

func (*Service) View

func (s *Service) View() *service.ViewService

View returns the view service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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