db

package
v0.0.0-...-8b6722b Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTx

func WithTx(ctx context.Context, client *ent.Client, fn func(tx *ent.Tx) error) error

WithTx wraps a function and executes it using a database transaction.

Types

type DbConfig

type DbConfig struct {
	Url                   string
	User                  string `env:"USER" envDefault:"postgres"`
	Password              string `env:"PASSWORD"`
	Host                  string `env:"HOST"`
	Port                  string `env:"PORT" envDefault:"5432"`
	Name                  string `env:"NAME"`
	MigrationsDir         string `env:"MIGRATIONS_DIR" envDefault:"ent/migrate/migrations"`
	AutoMigrate           bool   `env:"AUTO_MIGRATE" envDefault:"false"`
	AutoMigrateDropIndex  bool   `env:"AUTO_MIGRATE_DROP_INDEX" envDefault:"false"`
	AutoMigrateDropColumn bool   `env:"AUTO_MIGRATE_DROP_COLUMN" envDefault:"false"`
}

func (DbConfig) Validate

func (dbConfig DbConfig) Validate() error

type DbService

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

func NewDbService

func NewDbService(dbConfig DbConfig, logger logr.Logger) (*DbService, error)

func (*DbService) Client

func (dbService *DbService) Client() *ent.Client

func (*DbService) Close

func (dbService *DbService) Close() error

type DbServicer

type DbServicer interface {
	Client() *ent.Client
	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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