database

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseDatabaseImplement

type BaseDatabaseImplement struct {
	Db      *gorm.DB
	Logger  logger.Logger
	Timeout time.Duration
	// contains filtered or unexported fields
}

func (*BaseDatabaseImplement) Count

func (s *BaseDatabaseImplement) Count(table, query string, args ...any) (count int64, err error)

func (*BaseDatabaseImplement) CountWithCtx

func (s *BaseDatabaseImplement) CountWithCtx(ctx context.Context, table, query string, args ...any) (count int64, err error)

func (*BaseDatabaseImplement) DeleteAll

func (s *BaseDatabaseImplement) DeleteAll(query string, args ...any) error

func (*BaseDatabaseImplement) DeleteAllWithCtx

func (s *BaseDatabaseImplement) DeleteAllWithCtx(ctx context.Context, query string, args ...any) error

func (*BaseDatabaseImplement) DeleteOne

func (s *BaseDatabaseImplement) DeleteOne(query string, args ...any) error

func (*BaseDatabaseImplement) DeleteOneWithCtx

func (s *BaseDatabaseImplement) DeleteOneWithCtx(ctx context.Context, query string, args ...any) error

func (*BaseDatabaseImplement) ExecRaw

func (s *BaseDatabaseImplement) ExecRaw(sql string, args ...any) error

func (*BaseDatabaseImplement) ExecRawWithCtx

func (s *BaseDatabaseImplement) ExecRawWithCtx(ctx context.Context, sql string, args ...any) error

func (*BaseDatabaseImplement) GetAll

func (s *BaseDatabaseImplement) GetAll(receiver any, query string, args ...any) error

func (*BaseDatabaseImplement) GetAllWithCtx

func (s *BaseDatabaseImplement) GetAllWithCtx(ctx context.Context, receiver any, query string, args ...any) error

func (*BaseDatabaseImplement) GetOne

func (s *BaseDatabaseImplement) GetOne(receiver any, query string, args ...any) error

func (*BaseDatabaseImplement) GetOneWithCtx

func (s *BaseDatabaseImplement) GetOneWithCtx(ctx context.Context, receiver any, query string, args ...any) error

func (*BaseDatabaseImplement) GetPage

func (s *BaseDatabaseImplement) GetPage(receiver any, offset, limit int, query string, args ...any) error

func (*BaseDatabaseImplement) Has

func (s *BaseDatabaseImplement) Has(table, query string, args ...any) (exist bool, err error)

func (*BaseDatabaseImplement) HasWithCtx

func (s *BaseDatabaseImplement) HasWithCtx(ctx context.Context, table, query string, args ...any) (exist bool, err error)

func (*BaseDatabaseImplement) Init

func (s *BaseDatabaseImplement) Init(_ Options) error

func (*BaseDatabaseImplement) InsertAll

func (s *BaseDatabaseImplement) InsertAll(data any) error

func (*BaseDatabaseImplement) InsertAllWithCtx

func (s *BaseDatabaseImplement) InsertAllWithCtx(ctx context.Context, data any) error

func (*BaseDatabaseImplement) InsertOne

func (s *BaseDatabaseImplement) InsertOne(data any) error

func (*BaseDatabaseImplement) InsertOneWithCtx

func (s *BaseDatabaseImplement) InsertOneWithCtx(ctx context.Context, data any) error

func (*BaseDatabaseImplement) Migrate

func (s *BaseDatabaseImplement) Migrate(models ...any) error

func (*BaseDatabaseImplement) ParseDatabaseOptions

func (s *BaseDatabaseImplement) ParseDatabaseOptions(db *sql.DB, opts Options)

func (*BaseDatabaseImplement) ParseLoggerOptions

func (s *BaseDatabaseImplement) ParseLoggerOptions(opts Options)

func (*BaseDatabaseImplement) PickAll

func (s *BaseDatabaseImplement) PickAll(receiver any, length int, query string, args ...any) error

func (*BaseDatabaseImplement) PickAllWithCtx

func (s *BaseDatabaseImplement) PickAllWithCtx(ctx context.Context, receiver any, length int, query string, args ...any) error

func (*BaseDatabaseImplement) PickOne

func (s *BaseDatabaseImplement) PickOne(receiver any, query string, args ...any) error

func (*BaseDatabaseImplement) PickOneWithCtx

func (s *BaseDatabaseImplement) PickOneWithCtx(ctx context.Context, receiver any, query string, args ...any) error

func (*BaseDatabaseImplement) QueryRaw

func (s *BaseDatabaseImplement) QueryRaw(receiver any, sql string, args ...any) error

func (*BaseDatabaseImplement) QueryRawWithCtx

func (s *BaseDatabaseImplement) QueryRawWithCtx(ctx context.Context, receiver any, sql string, args ...any) error

func (*BaseDatabaseImplement) SetRandCommand

func (s *BaseDatabaseImplement) SetRandCommand(command string)

func (*BaseDatabaseImplement) UpdateAll

func (s *BaseDatabaseImplement) UpdateAll(data any, query string, args ...any) error

func (*BaseDatabaseImplement) UpdateAllWithCtx

func (s *BaseDatabaseImplement) UpdateAllWithCtx(ctx context.Context, data any, query string, args ...any) error

func (*BaseDatabaseImplement) UpdateOne

func (s *BaseDatabaseImplement) UpdateOne(data any, query string, args ...any) error

func (*BaseDatabaseImplement) UpdateOneWithCtx

func (s *BaseDatabaseImplement) UpdateOneWithCtx(ctx context.Context, data any, query string, args ...any) error

type Database

type Database interface {
	Init(options Options) error
	Migrate(models ...any) error
	Has(table string, query string, args ...any) (exist bool, err error)
	Count(table string, query string, args ...any) (count int64, err error)
	GetOne(receiver any, query string, args ...any) error
	GetAll(receiver any, query string, args ...any) error
	GetPage(receiver any, offset, limit int, query string, args ...any) error
	PickOne(receiver any, query string, args ...any) error
	PickAll(receiver any, length int, query string, args ...any) error
	InsertOne(data any) error
	InsertAll(data any) error
	UpdateOne(data any, query string, args ...any) error
	UpdateAll(data any, query string, args ...any) error
	DeleteOne(query string, args ...any) error
	DeleteAll(query string, args ...any) error
	ExecRaw(sql string, args ...any) error
	QueryRaw(receiver any, sql string, args ...any) error
	HasWithCtx(ctx context.Context, table string, query string, args ...any) (exist bool, err error)
	CountWithCtx(ctx context.Context, table string, query string, args ...any) (count int64, err error)
	GetOneWithCtx(ctx context.Context, receiver any, query string, args ...any) error
	GetAllWithCtx(ctx context.Context, receiver any, query string, args ...any) error
	PickOneWithCtx(ctx context.Context, receiver any, query string, args ...any) error
	PickAllWithCtx(ctx context.Context, receiver any, length int, query string, args ...any) error
	InsertOneWithCtx(ctx context.Context, data any) error
	InsertAllWithCtx(ctx context.Context, data any) error
	UpdateOneWithCtx(ctx context.Context, data any, query string, args ...any) error
	UpdateAllWithCtx(ctx context.Context, data any, query string, args ...any) error
	DeleteOneWithCtx(ctx context.Context, query string, args ...any) error
	DeleteAllWithCtx(ctx context.Context, query string, args ...any) error
	ExecRawWithCtx(ctx context.Context, sql string, args ...any) error
	QueryRawWithCtx(ctx context.Context, receiver any, sql string, args ...any) error
}

type Options

type Options struct {
	DataSource string
	MaxIdle    int
	MaxOpen    int
	MaxLife    time.Duration
	Timeout    time.Duration
	Stdout     string
	Stderr     string
	DebugLog   bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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