db

package
v0.6.36 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 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(opt Options) *Db

func (*Db) Await added in v0.2.73

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

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) 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) 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) Upsert

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

func (*Db) Wait

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

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, lock bool, rollbackLast bool, previewDown bool, repairDown bool) (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 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
	LogErrors       bool
	LogQueries      bool
	LogLongQueries  bool
	WarnLongQueries bool
	LongQueriesTime time.Duration
	ReadOnly        bool
}

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