gorm

package
v0.0.0-...-057734e Latest Latest
Warning

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

Go to latest
Published: Feb 16, 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 MysqlDocker

func MysqlDocker() (*dockertest.Pool, *dockertest.Resource, ormcontract.DB, error)

func New

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

func NewLogger

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

NewLogger initialize Logger

func PostgresqlDocker

func PostgresqlDocker() (*dockertest.Pool, *dockertest.Resource, ormcontract.DB, error)

func SqliteDocker

func SqliteDocker() (*dockertest.Pool, *dockertest.Resource, ormcontract.DB, error)

func SqlserverDocker

func SqlserverDocker() (*dockertest.Pool, *dockertest.Resource, ormcontract.DB, error)

Types

type DB

type DB struct {
	ormcontract.Query
	// contains filtered or unexported fields
}

func NewDB

func NewDB(ctx context.Context, connection string) (*DB, error)

func (*DB) Begin

func (r *DB) Begin() (ormcontract.Transaction, error)

func (*DB) Instance

func (r *DB) Instance() *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 Query

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

func NewQuery

func NewQuery(instance *gorm.DB) *Query

func (*Query) Association

func (r *Query) Association(association string) ormcontract.Association

func (*Query) Count

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

func (*Query) Create

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

func (*Query) Delete

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

func (*Query) Distinct

func (r *Query) Distinct(args ...any) ormcontract.Query

func (*Query) Driver

func (r *Query) Driver() ormcontract.Driver

func (*Query) Exec

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

func (*Query) Find

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

func (*Query) First

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

func (*Query) FirstOrCreate

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

func (*Query) ForceDelete

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

func (*Query) Get

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

func (*Query) Group

func (r *Query) Group(name string) ormcontract.Query

func (*Query) Having

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

func (*Query) Join

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

func (*Query) Limit

func (r *Query) Limit(limit int) ormcontract.Query

func (*Query) Load

func (r *Query) Load(model any, relation string, args ...any) error

func (*Query) LoadMissing

func (r *Query) LoadMissing(model any, relation string, args ...any) error

func (*Query) Model

func (r *Query) Model(value any) ormcontract.Query

func (*Query) Offset

func (r *Query) Offset(offset int) ormcontract.Query

func (*Query) Omit

func (r *Query) Omit(columns ...string) ormcontract.Query

func (*Query) OrWhere

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

func (*Query) Order

func (r *Query) Order(value any) ormcontract.Query

func (*Query) Paginate

func (r *Query) Paginate(page, limit int, dest any, total *int64) error

func (*Query) Pluck

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

func (*Query) Raw

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

func (*Query) Save

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

func (*Query) Scan

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

func (*Query) Scopes

func (r *Query) Scopes(funcs ...func(ormcontract.Query) ormcontract.Query) ormcontract.Query

func (*Query) Select

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

func (*Query) Table

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

func (*Query) Update

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

func (*Query) Updates

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

func (*Query) Where

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

func (*Query) With

func (r *Query) With(query string, args ...any) ormcontract.Query

func (*Query) WithTrashed

func (r *Query) WithTrashed() ormcontract.Query

type Transaction

type Transaction struct {
	ormcontract.Query
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction(instance *gorm.DB) *Transaction

func (*Transaction) Commit

func (r *Transaction) Commit() error

func (*Transaction) Rollback

func (r *Transaction) Rollback() error

Jump to

Keyboard shortcuts

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