database

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileWithLineNum

func FileWithLineNum() string

FileWithLineNum return the file name and line number of the current file

func GetDsn

func GetDsn(connection string) (string, error)

func New

func New(writer logger.Writer, config logger.Config) logger.Interface

New initialize Logger

func NewGormDB

func NewGormDB(ctx context.Context, connection string) (contractsorm.DB, error)

func NewGormInstance

func NewGormInstance(connection string) (*gorm.DB, error)

func NewGormQuery

func NewGormQuery(instance *gorm.DB) contractsorm.Query

func NewGormTransaction

func NewGormTransaction(instance *gorm.DB) contractsorm.Transaction

func NewOrm

func NewOrm() contractsorm.Orm

Types

type Application

type Application struct {
}

func (*Application) Init

func (app *Application) Init() orm.Orm

type DB

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

func (*DB) Connection

func (r *DB) Connection(name string) database.DB

func (*DB) Query

func (r *DB) Query() database.Sqlx

func (*DB) Transaction

func (r *DB) Transaction(ctx context.Context, txFunc func(tx *sqlx.Tx) error) error

type GormDB

type GormDB struct {
	contractsorm.Query
	// contains filtered or unexported fields
}

func (*GormDB) Begin

func (r *GormDB) Begin() (contractsorm.Transaction, error)

type GormQuery

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

func (*GormQuery) Count

func (r *GormQuery) Count(count *int64) error

func (*GormQuery) Create

func (r *GormQuery) Create(value any) error

func (*GormQuery) Delete

func (r *GormQuery) Delete(value any, conds ...any) error

func (*GormQuery) Distinct

func (r *GormQuery) Distinct(args ...any) contractsorm.Query

func (*GormQuery) Exec

func (r *GormQuery) Exec(sql string, values ...any) error

func (*GormQuery) Find

func (r *GormQuery) Find(dest any, conds ...any) error

func (*GormQuery) First

func (r *GormQuery) First(dest any) error

func (*GormQuery) FirstOrCreate

func (r *GormQuery) FirstOrCreate(dest any, conds ...any) error

func (*GormQuery) ForceDelete

func (r *GormQuery) ForceDelete(value any, conds ...any) error

func (*GormQuery) Get

func (r *GormQuery) Get(dest any) error

func (*GormQuery) Group

func (r *GormQuery) Group(name string) contractsorm.Query

func (*GormQuery) Having

func (r *GormQuery) Having(query any, args ...any) contractsorm.Query

func (*GormQuery) Join

func (r *GormQuery) Join(query string, args ...any) contractsorm.Query

func (*GormQuery) Limit

func (r *GormQuery) Limit(limit int) contractsorm.Query

func (*GormQuery) Model

func (r *GormQuery) Model(value any) contractsorm.Query

func (*GormQuery) Offset

func (r *GormQuery) Offset(offset int) contractsorm.Query

func (*GormQuery) OrWhere

func (r *GormQuery) OrWhere(query any, args ...any) contractsorm.Query

func (*GormQuery) Order

func (r *GormQuery) Order(value any) contractsorm.Query

func (*GormQuery) Pluck

func (r *GormQuery) Pluck(column string, dest any) error

func (*GormQuery) Raw

func (r *GormQuery) Raw(sql string, values ...any) contractsorm.Query

func (*GormQuery) Save

func (r *GormQuery) Save(value any) error

func (*GormQuery) Scan

func (r *GormQuery) Scan(dest any) error

func (*GormQuery) Scopes

func (r *GormQuery) Scopes(funcs ...func(contractsorm.Query) contractsorm.Query) contractsorm.Query

func (*GormQuery) Select

func (r *GormQuery) Select(query any, args ...any) contractsorm.Query

func (*GormQuery) Table

func (r *GormQuery) Table(name string, args ...any) contractsorm.Query

func (*GormQuery) Update

func (r *GormQuery) Update(column string, value any) error

func (*GormQuery) Updates

func (r *GormQuery) Updates(values any) error

func (*GormQuery) Where

func (r *GormQuery) Where(query any, args ...any) contractsorm.Query

func (*GormQuery) WithTrashed

func (r *GormQuery) WithTrashed() contractsorm.Query

type GormTransaction

type GormTransaction struct {
	contractsorm.Query
	// contains filtered or unexported fields
}

func (*GormTransaction) Commit

func (r *GormTransaction) Commit() error

func (*GormTransaction) Rollback

func (r *GormTransaction) Rollback() error

type Logger

type Logger struct {
	logger.Writer
	logger.Config
	// contains filtered or unexported fields
}

func (Logger) Error

func (l Logger) Error(ctx context.Context, msg string, data ...any)

Error print error messages

func (Logger) Info

func (l Logger) Info(ctx context.Context, msg string, data ...any)

Info print info

func (*Logger) LogMode

func (l *Logger) LogMode(level logger.LogLevel) logger.Interface

LogMode log mode

func (Logger) Trace

func (l Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace print sql message

func (Logger) Warn

func (l Logger) Warn(ctx context.Context, msg string, data ...any)

Warn print warn messages

type Orm

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

func (*Orm) Connection

func (r *Orm) Connection(name string) contractsorm.Orm

func (*Orm) Query

func (r *Orm) Query() contractsorm.DB

func (*Orm) Transaction

func (r *Orm) Transaction(txFunc func(tx contractsorm.Transaction) error) error

func (*Orm) WithContext

func (r *Orm) WithContext(ctx context.Context) contractsorm.Orm

type ServiceProvider

type ServiceProvider struct {
}

func (*ServiceProvider) Boot

func (database *ServiceProvider) Boot()

func (*ServiceProvider) Register

func (database *ServiceProvider) Register()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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