gorm

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 30 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorMissingWhereClause = errors.New("WHERE conditions required")
)

Functions

func Configs added in v1.9.0

func Configs(connection string) (readConfigs, writeConfigs []contractsdatabase.Config, err error)

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, contractsorm.DB, error)

func MysqlDsn added in v1.9.0

func MysqlDsn(connection string, config contractsdatabase.Config) string

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, contractsorm.DB, error)

func PostgresqlDsn added in v1.9.0

func PostgresqlDsn(connection string, config contractsdatabase.Config) string

func SqliteDocker

func SqliteDocker(dbName string) (*dockertest.Pool, *dockertest.Resource, contractsorm.DB, error)

func SqliteDsn added in v1.9.0

func SqliteDsn(config contractsdatabase.Config) string

func SqlserverDocker

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

func SqlserverDsn added in v1.9.0

func SqlserverDsn(connection string, config contractsdatabase.Config) string

Types

type DB

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

func NewDB

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

func (*DB) Begin

func (r *DB) Begin() (contractsorm.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) contractsorm.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) contractsorm.Query

func (*Query) Driver

func (r *Query) Driver() contractsorm.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) contractsorm.Query

func (*Query) Having

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

func (*Query) Join

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

func (*Query) Limit

func (r *Query) Limit(limit int) contractsorm.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) contractsorm.Query

func (*Query) Offset

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

func (*Query) Omit

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

func (*Query) OrWhere

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

func (*Query) Order

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

func (*Query) Paginate added in v1.9.0

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) contractsorm.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(contractsorm.Query) contractsorm.Query) contractsorm.Query

func (*Query) Select

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

func (*Query) Table

func (r *Query) Table(name string, args ...any) contractsorm.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) contractsorm.Query

func (*Query) With

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

func (*Query) WithTrashed

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

type Transaction

type Transaction struct {
	contractsorm.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