db

package
v0.0.0-...-e89c278 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBatchesStop = errors.New("batches stop")

Functions

func AutoMigrate

func AutoMigrate(dst ...interface{}) error

func Begin

func Begin() *gorm.DB

func Clauses

func Clauses(conds ...clause.Expression) *gorm.DB

func CommitOrRollback

func CommitOrRollback(tx *gorm.DB, logic func() error) error

func Connect

func Connect(c Config, tables ...interface{}) error

func Create

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

func CreateInBatches

func CreateInBatches(value interface{}, batchSize int) *gorm.DB

func Find

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

func FindInBatches

func FindInBatches(dest interface{}, batchSize int, fc func(tx *gorm.DB, batch int) error) *gorm.DB

func FirstOrCreate

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

func IsUniqueIndexConflictErr

func IsUniqueIndexConflictErr(err error) bool

func Model

func Model(model interface{}) *gorm.DB

func Order

func Order(value interface{}) *gorm.DB

func Save

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

func Select

func Select(query interface{}, args ...interface{}) *gorm.DB

func Statement

func Statement() *gorm.Statement

func Transaction

func Transaction(logic func(tx *gorm.DB) error) error

func Unscoped

func Unscoped() *gorm.DB

func Where

func Where(query interface{}, args ...interface{}) *gorm.DB

Types

type Config

type Config struct {
	Dsn      string   `json:"dsn,omitempty"`
	Database Database `json:"database,omitempty"`
	Debug    bool     `json:"debug,omitempty"`

	DriverName string `json:"driver,omitempty"`

	Logger logger.Interface `json:"logger,omitempty"`
}

type Database

type Database string
const (
	MySql      Database = "mysql"
	Postgres   Database = "postgres"
	Sqlite     Database = "sqlite"
	Sqlserver  Database = "sqlserver"
	Clickhouse Database = "clickhouse"
)

type Logger

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

func NewDiscard

func NewDiscard() *Logger

func NewLogger

func NewLogger() *Logger

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, s string, i ...interface{})

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, s string, i ...interface{})

func (*Logger) LogMode

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

func (*Logger) Trace

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

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, s string, i ...interface{})

Jump to

Keyboard shortcuts

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