database

package
v1.0.87 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 27 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, config *gorm.Config, disableLog bool) (orm.DB, error)

func NewGormInstance

func NewGormInstance(connection string, config *gorm.Config, disableLog bool) (*gorm.DB, error)

func NewGormQuery

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

func NewGormTransaction

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

func NewLog

func NewLog(logger *log.Logger, config logger.Config, silent bool) logger.Interface

func NewOrm

func NewOrm(ctx context.Context, name string, config *gorm.Config, disableLog bool) contractsorm.Orm

Types

type Application

type Application struct {
	Config     *gorm.Config
	Name       string
	DisableLog bool
}

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 Field added in v1.0.76

type Field struct {
	Name string `gorm:"column:name"`
}

type GormDB

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

func (*GormDB) Begin

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

func (*GormDB) Instance

func (r *GormDB) Instance() *gorm.DB

type GormQuery

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

func (*GormQuery) Count

func (r *GormQuery) Count(count *int64) *gorm.DB

func (*GormQuery) Create

func (r *GormQuery) Create(value interface{}) *gorm.DB

func (*GormQuery) Delete

func (r *GormQuery) Delete(value interface{}, conds ...interface{}) *gorm.DB

func (*GormQuery) Distinct

func (r *GormQuery) Distinct(args ...interface{}) orm.Query

func (*GormQuery) Driver

func (r *GormQuery) Driver() orm.Driver

func (*GormQuery) Exec

func (r *GormQuery) Exec(sql string, values ...interface{}) *gorm.DB

func (*GormQuery) Fields added in v1.0.75

func (r *GormQuery) Fields(schema, name string) (fields []string, err error)

func (*GormQuery) Find

func (r *GormQuery) Find(dest interface{}, conds ...interface{}) *gorm.DB

func (*GormQuery) First

func (r *GormQuery) First(dest interface{}) *gorm.DB

func (*GormQuery) FirstOrCreate

func (r *GormQuery) FirstOrCreate(dest interface{}, conds ...interface{}) *gorm.DB

func (*GormQuery) ForceDelete

func (r *GormQuery) ForceDelete(value interface{}, conds ...interface{}) *gorm.DB

func (*GormQuery) Get

func (r *GormQuery) Get(dest interface{}) *gorm.DB

func (*GormQuery) Group

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

func (*GormQuery) Having

func (r *GormQuery) Having(query interface{}, args ...interface{}) orm.Query

func (*GormQuery) Instance added in v1.0.87

func (r *GormQuery) Instance() *gorm.DB

func (*GormQuery) Join

func (r *GormQuery) Join(query string, args ...interface{}) orm.Query

func (*GormQuery) Limit

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

func (*GormQuery) Model

func (r *GormQuery) Model(value interface{}) orm.Query

func (*GormQuery) Offset

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

func (*GormQuery) OrWhere

func (r *GormQuery) OrWhere(query interface{}, args ...interface{}) orm.Query

func (*GormQuery) Order

func (r *GormQuery) Order(value interface{}) orm.Query

func (*GormQuery) Pluck

func (r *GormQuery) Pluck(column string, dest interface{}) *gorm.DB

func (*GormQuery) Raw

func (r *GormQuery) Raw(sql string, values ...interface{}) orm.Query

func (*GormQuery) Save

func (r *GormQuery) Save(value interface{}) *gorm.DB

func (*GormQuery) Scan

func (r *GormQuery) Scan(dest interface{}) *gorm.DB

func (*GormQuery) Scopes

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

func (*GormQuery) Select

func (r *GormQuery) Select(query interface{}, args ...interface{}) orm.Query

func (*GormQuery) Table

func (r *GormQuery) Table(name string, args ...interface{}) orm.Query

func (*GormQuery) Update

func (r *GormQuery) Update(column string, value interface{}) *gorm.DB

func (*GormQuery) Updates

func (r *GormQuery) Updates(values interface{}) *gorm.DB

func (*GormQuery) Where

func (r *GormQuery) Where(query interface{}, args ...interface{}) orm.Query

func (*GormQuery) With

func (r *GormQuery) With(query string, args ...interface{}) orm.Query

func (*GormQuery) WithContext added in v1.0.86

func (r *GormQuery) WithContext(ctx context.Context) orm.Query

func (*GormQuery) WithTrashed

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

type GormTransaction

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

func (*GormTransaction) Commit

func (r *GormTransaction) Commit() *gorm.DB

func (*GormTransaction) Rollback

func (r *GormTransaction) Rollback() *gorm.DB

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 {
	Name string
	// contains filtered or unexported fields
}

func (*Orm) Connection

func (r *Orm) Connection(name string, config *gorm.Config, disableLog bool) contractsorm.Orm

func (*Orm) Query

func (r *Orm) Query(database ...string) 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 {
	Config     *gorm.Config
	DisableLog bool
	Name       string
}

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