database

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DBHost           string `env:"DB_HOST,required"`
	DBPassword       string `env:"DB_PASSWORD,required"`
	DBUser           string `emv:"DB_USER,required"`
	DBName           string `env:"DB_NAME,required"`
	DBPort           string `env:"DB_PORT,required"`
	SSLMode          string `env:"SSL_MODE,required"`
	CreateBatchSize  int    `env:"CREATE_BATCH_SIZE" envDefault:"2000"`
	ConnectionsLimit int    `env:"CONNECTIONS_LIMIT" envDefault:"1000"`
}

func (*Config) DSN

func (c *Config) DSN() string

type Database

type Database struct {
	Connection *gorm.DB
	Config     *Config
	Logger     util.Logger
	// contains filtered or unexported fields
}

func MustNewDB

func MustNewDB(db *gorm.DB, driver Driver, cfg *Config, logger util.Logger) *Database

func (*Database) Close

func (db *Database) Close() error

func (*Database) Delete

func (db *Database) Delete(object interface{}, model interface{}) error

func (*Database) Find

func (db *Database) Find(object interface{}, model interface{}) ([]interface{}, error)

func (*Database) Migrate

func (db *Database) Migrate(models ...interface{}) error

func (*Database) Upsert

func (db *Database) Upsert(object interface{}, model interface{}) error

func (*Database) UpsertBatch

func (db *Database) UpsertBatch(objects []interface{}, model interface{}) error

type Driver

type Driver interface {
	Upsert(object interface{}, model interface{}) error
	UpsertBatch(objects []interface{}, model interface{}) error
	Find(object interface{}, model interface{}) ([]interface{}, error)
	Delete(object interface{}, model interface{}) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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