db

package
v0.0.0-...-fad138e Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func IsUniqueIndexConflictErr

func IsUniqueIndexConflictErr(err error) bool

Types

type Client

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

func NewClient

func NewClient(c Config, tables ...interface{}) (*Client, error)

func (*Client) AutoMigrate

func (p *Client) AutoMigrate(dst ...interface{}) error

func (*Client) Begin

func (p *Client) Begin() *gorm.DB

func (*Client) Clauses

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

func (*Client) CommitOrRollback

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

func (*Client) Create

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

func (*Client) CreateInBatches

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

func (*Client) Find

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

func (*Client) FindInBatches

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

func (*Client) FirstOrCreate

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

func (*Client) Model

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

func (*Client) Order

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

func (*Client) Save

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

func (*Client) Select

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

func (*Client) Statement

func (p *Client) Statement() *gorm.Statement

func (*Client) Transaction

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

func (*Client) Unscoped

func (p *Client) Unscoped() *gorm.DB

func (*Client) Where

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

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