gorm

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 35 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, orm.Query, 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, orm.Query, 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, orm.Query, error)

func SqliteDsn added in v1.9.0

func SqliteDsn(config contractsdatabase.Config) string

func SqlserverDocker

func SqlserverDocker() (*dockertest.Pool, *dockertest.Resource, orm.Query, error)

func SqlserverDsn added in v1.9.0

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

Types

type Event added in v1.11.0

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

func NewEvent added in v1.11.0

func NewEvent(query *Query, model, dest any) *Event

func (*Event) ColumnNamesWithDbColumnNames added in v1.11.0

func (e *Event) ColumnNamesWithDbColumnNames() map[string]string

func (*Event) Context added in v1.11.0

func (e *Event) Context() context.Context

func (*Event) DestOfMap added in v1.11.0

func (e *Event) DestOfMap() map[string]any

func (*Event) GetAttribute added in v1.11.0

func (e *Event) GetAttribute(key string) any

func (*Event) GetOriginal added in v1.11.0

func (e *Event) GetOriginal(key string, def ...any) any

func (*Event) IsClean added in v1.11.0

func (e *Event) IsClean(fields ...string) bool

func (*Event) IsDirty added in v1.11.0

func (e *Event) IsDirty(columns ...string) bool

func (*Event) ModelOfMap added in v1.11.0

func (e *Event) ModelOfMap() map[string]any

func (*Event) Query added in v1.11.0

func (e *Event) Query() orm.Query

func (*Event) SetAttribute added in v1.11.0

func (e *Event) SetAttribute(key string, value any)

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(ctx context.Context, connection string) (*Query, error)

func NewQueryWithInstance added in v1.11.0

func NewQueryWithInstance(query *Query, instance *gorm.DB) *Query

func NewQueryWithWithoutEvents added in v1.11.0

func NewQueryWithWithoutEvents(query *Query) *Query

func (*Query) Association

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

func (*Query) Begin added in v1.10.0

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

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(dest any, conds ...any) (*contractsorm.Result, 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) (*contractsorm.Result, error)

func (*Query) Find

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

func (*Query) FindOrFail added in v1.11.0

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

func (*Query) First

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

func (*Query) FirstOr added in v1.10.0

func (r *Query) FirstOr(dest any, callback func() error) error

func (*Query) FirstOrCreate

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

func (*Query) FirstOrFail added in v1.10.0

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

func (*Query) FirstOrNew added in v1.10.0

func (r *Query) FirstOrNew(dest any, attributes any, values ...any) error

func (*Query) ForceDelete

func (r *Query) ForceDelete(value any, conds ...any) (*contractsorm.Result, 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) Instance added in v1.10.0

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

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) LockForUpdate added in v1.11.0

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

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) SaveQuietly added in v1.11.0

func (r *Query) SaveQuietly(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) SharedLock added in v1.11.0

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

func (*Query) Table

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

func (*Query) Update

func (r *Query) Update(column any, value ...any) (*contractsorm.Result, error)

func (*Query) UpdateOrCreate added in v1.10.0

func (r *Query) UpdateOrCreate(dest any, attributes any, 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

func (*Query) WithoutEvents added in v1.11.0

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

type Transaction

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

func NewTransaction

func NewTransaction(tx *gorm.DB) *Transaction

func (*Transaction) Commit

func (r *Transaction) Commit() error

func (*Transaction) Rollback

func (r *Transaction) Rollback() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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