db

package
v0.2.55 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

func (*Db) DeleteAll

func (o *Db) DeleteAll(model any) 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) Ok

func (o *Db) Ok() bool

func (*Db) Ping

func (o *Db) Ping() bool

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

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

func (*Db) Wait

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

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
}

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)

Jump to

Keyboard shortcuts

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