database

package
v0.0.0-...-dbd5446 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostGreType = iota
	MySQLType
)
View Source
const (
	MaxIdle        = 0
	MaxConnections = 10
)

Variables

This section is empty.

Functions

func Connect

func Connect(c *Config) (*gorm.DB, error)

Types

type Config

type Config struct {
	Host         string
	Port         int
	Database     string
	User         string
	Pass         string
	DatabaseType int
	SSLMode      string
}

func (*Config) ConnectionString

func (c *Config) ConnectionString() *string

type Database

type Database struct {
	Orm *gorm.DB
}

func NewDatabase

func NewDatabase(orm *gorm.DB) *Database

func (*Database) CountAll

func (d *Database) CountAll(mod model.Model) int64

func (*Database) Create

func (d *Database) Create(mod model.Model) error

func (*Database) Delete

func (d *Database) Delete(mod model.Model) error

func (*Database) FetchAll

func (d *Database) FetchAll(mod model.Model, rows interface{}) error

func (*Database) FetchLatest

func (d *Database) FetchLatest(mod model.Model, creationColumn string) error

func (*Database) FetchOne

func (d *Database) FetchOne(mod model.Model) error

func (*Database) FetchOnly

func (d *Database) FetchOnly(mod model.Model, limit int, rows interface{}) error

func (*Database) FetchPage

func (d *Database) FetchPage(
	mod model.Model,
	limit int,
	offset int,
	rows interface{},
) error

func (*Database) Save

func (d *Database) Save(mod model.Model) error

func (*Database) Transaction

func (d *Database) Transaction(transaction func(tx *gorm.DB) error) error

func (*Database) Upsert

func (d *Database) Upsert(mod model.Model) error

type Repository

type Repository struct {
	Database *Database
	Logger   *zap.Logger
}

func (*Repository) Create

func (r *Repository) Create(m model.Model) error

func (*Repository) Find

func (r *Repository) Find(m model.Model) error

func (*Repository) Save

func (r *Repository) Save(m model.Model) error

Jump to

Keyboard shortcuts

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