db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToConnectDatabase = errors.New("ERR_FAILED_TO_CONNECT_DATABASE")
	ErrFailedToMigrateDatabase = errors.New("ERR_FAILED_TO_MIGRATE_DATABASE")
)

ProviderSet is a wire provider set that provides the database connection.

Functions

func ProvideConnection

func ProvideConnection(dsn config.DSN) (*gorm.DB, error)

ProvideConnection provides a new database connection.

func ProvideDSN

func ProvideDSN(cfg *config.Config) config.DSN

ProvideDSN provides the DSN from the config.

Types

type Database

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

Database is the database connection.

func NewDatabase

func NewDatabase(conn *gorm.DB, models ModelsInterface) *Database

NewDatabase creates a new Database instance.

func ProvideDatabase

func ProvideDatabase(conn *gorm.DB, models ModelsInterface) (*Database, error)

ProvideDatabase provides a new database connection.

func (*Database) GetConn

func (d *Database) GetConn() *gorm.DB

GetConn returns the database connection.

func (*Database) Models

func (d *Database) Models() ModelsInterface

Models returns the database models.

type DatabaseInterface

type DatabaseInterface interface {
	GetConn() *gorm.DB
	Models() ModelsInterface
}

DatabaseInterface is the interface for the database.

type Models

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

Models is a collection of all models in the database.

func NewModels

NewModels creates a new Models instance.

func ProvideModels

func ProvideModels(conn *gorm.DB) *Models

ProvideModels provides the models.

func (*Models) Posts

Posts returns the models.PostRepository.

func (*Models) Subscribers

func (m *Models) Subscribers() models.SubscriberRepositoryInterface

Subscribers returns the models.SubscriberRepository.

func (*Models) Users

Users returns the models.UserRepository.

type ModelsInterface

type ModelsInterface interface {
	Users() models.UserRepositoryInterface
	Posts() models.PostRepositoryInterface
	Subscribers() models.SubscriberRepositoryInterface
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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