db

package
v0.7.52 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count added in v0.2.66

func Count[T any](o *Db) (int, error)

func Delete added in v0.2.68

func Delete[T any](o *Db, fn func(*bun.DeleteQuery)) (int64, error)

func DeleteAll added in v0.2.68

func DeleteAll[T any](o *Db) (int64, error)

func Diff added in v0.2.8

func Diff[T any](a, b T) []string

func Equal added in v0.2.8

func Equal[T any](a, b T) bool

func PkName added in v0.2.7

func PkName(model any) (name string, err error)

func UpdateDiff added in v0.2.8

func UpdateDiff[T any](db *Db, prev, curr T) (columns []string, err error)

Types

type Db

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

func New added in v0.2.8

func New(opts Options) *Db

func (*Db) Close

func (o *Db) Close()

func (*Db) Count

func (o *Db) Count(model any) (int, error)

func (*Db) Delete

func (o *Db) Delete(model any, fn func(*bun.DeleteQuery)) (int64, error)

func (*Db) DeleteAll

func (o *Db) DeleteAll(model any) (int64, error)

func (*Db) Exec

func (o *Db) Exec(query string, arg ...any) error

func (*Db) Exists

func (o *Db) Exists(model any, fn func(*bun.SelectQuery)) (bool, error)

func (*Db) ExistsPk

func (o *Db) ExistsPk(model any) (bool, error)

func (*Db) Format

func (o *Db) Format(query string, arg ...any) string

func (*Db) GetIfExists

func (o *Db) GetIfExists(model any, fn func(*bun.SelectQuery)) (bool, error)

func (*Db) GetIfExistsPk

func (o *Db) GetIfExistsPk(model any) (bool, error)

func (*Db) Insert

func (o *Db) Insert(model any) error

func (*Db) Migrator added in v0.4.2

func (o *Db) Migrator() *Migrator

func (*Db) NewSelect added in v0.2.69

func (o *Db) NewSelect(model any) *bun.SelectQuery

func (*Db) Ok

func (o *Db) Ok() bool

func (*Db) OnReady added in v0.7.8

func (o *Db) OnReady(f func())

func (*Db) OnReadyFor added in v0.7.8

func (o *Db) OnReadyFor(f func(), timeout time.Duration)

func (*Db) Ping

func (o *Db) Ping() bool

func (*Db) Scan added in v0.5.30

func (o *Db) Scan(model any, query string, arg ...any) error

func (*Db) Select

func (o *Db) Select(model any, fn func(*bun.SelectQuery)) error

func (*Db) SelectAll

func (o *Db) SelectAll(model any) error

func (*Db) SelectIn added in v0.2.29

func (o *Db) SelectIn(model any, ids any) error

func (*Db) SelectPk added in v0.6.12

func (o *Db) SelectPk(model any) error

func (*Db) Transaction added in v0.7.36

func (o *Db) Transaction(f func(ctx context.Context, tx bun.Tx) error) error

func (*Db) Truncate

func (o *Db) Truncate(model any) error

func (*Db) Update

func (o *Db) Update(model any, fn func(*bun.UpdateQuery)) error

func (*Db) UpdateAll

func (o *Db) UpdateAll(model any) error

func (*Db) UpdateIn

func (o *Db) UpdateIn(model any, ids any) error

func (*Db) UpdatePk added in v0.6.13

func (o *Db) UpdatePk(model any) error

func (*Db) UpdatePkOmitZero added in v0.7.52

func (o *Db) UpdatePkOmitZero(model any) error

func (*Db) Upsert

func (o *Db) Upsert(model any) error

func (*Db) Wait

func (o *Db) Wait(timeout time.Duration) bool

func (*Db) WaitForReady added in v0.7.8

func (o *Db) WaitForReady(timeout time.Duration) time.Duration

type Hosts added in v0.7.8

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

func NewHosts added in v0.7.8

func NewHosts(s string) *Hosts

func (Hosts) Count added in v0.7.8

func (o Hosts) Count() int

func (Hosts) IsMulti added in v0.7.8

func (o Hosts) IsMulti() bool

func (*Hosts) Loop added in v0.7.8

func (o *Hosts) Loop(f func(string) bool)

func (*Hosts) Next added in v0.7.8

func (o *Hosts) Next() (v string)

func (Hosts) String added in v0.7.8

func (o Hosts) String() string

type Migrator added in v0.4.2

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

func NewMigrator added in v0.4.2

func NewMigrator(d *Db) *Migrator

func (*Migrator) Exec added in v0.4.2

func (o *Migrator) Exec(fs fs.FS) bool

func (*Migrator) ExecOpt added in v0.7.38

func (o *Migrator) ExecOpt(fs fs.FS, opt MigratorOptions) (ok bool)

func (*Migrator) WithAutoDownSql added in v0.4.2

func (o *Migrator) WithAutoDownSql(v bool) *Migrator

func (*Migrator) WithMarkAppliedOnSuccess added in v0.4.2

func (o *Migrator) WithMarkAppliedOnSuccess(v bool) *Migrator

func (*Migrator) WithRollbackLost added in v0.4.2

func (o *Migrator) WithRollbackLost(v bool) *Migrator

func (*Migrator) WithSaveDownSql added in v0.4.2

func (o *Migrator) WithSaveDownSql(v bool) *Migrator

type MigratorAction added in v0.7.38

type MigratorAction string
const (
	Migrate     MigratorAction = ""
	Rollback    MigratorAction = "rollback"
	PreviewDown MigratorAction = "preview-down"
	RepairDown  MigratorAction = "repair-down"
	ViewSchema  MigratorAction = "view-schema"
)

type MigratorOptions added in v0.7.38

type MigratorOptions struct {
	Action       MigratorAction
	Lock         bool
	TraceSchema  bool
	PrettySchema bool
	Final        string
	Migration    string
}

type Options added in v0.2.7

type Options struct {
	User            string
	Pass            string
	Host            string
	Name            string
	Timeout         time.Duration
	MaxConnFactor   float32
	MinOpenConns    int
	Strict          bool
	Insecure        bool
	DisablePrepared bool
	LogErrors       bool
	LogQueries      bool
	LogLongQueries  bool
	WarnLongQueries bool
	LongQueriesTime time.Duration
	ReadOnly        bool
}

func (Options) MaxOpenConnections added in v0.7.8

func (o Options) MaxOpenConnections() int

type Updater added in v0.2.8

type Updater[T any] struct {
	// contains filtered or unexported fields
}

func NewUpdater added in v0.2.8

func NewUpdater[T any](db *Db, v T) *Updater[T]

func (*Updater[T]) Equal added in v0.2.8

func (o *Updater[T]) Equal(v T) bool

func (*Updater[T]) Last added in v0.2.50

func (o *Updater[T]) Last() T

func (*Updater[T]) Update added in v0.2.8

func (o *Updater[T]) Update(v T) (columns []string, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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