db

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Ref = Reflect.New[[]string](func(self *Reflect.Reflect[[]string], field reflect.StructField, elem reflect.Type) []string {
	if _, ok := elem.FieldByName(field.Name + "ID"); !ok {
		return []string{}
	}

	preloads := make([][]string, 0)
	if !self.GetType(field.Type, &preloads) {
		return []string{}
	}

	r := make([]string, 0)
	for _, preload := range preloads {
		for _, s := range preload {
			r = append(r, fmt.Sprintf("%v.%v", field.Name, s))
		}
	}

	if len(r) == 0 {
		return []string{field.Name}
	}
	return r
}, func(r *Reflect.Reflect[[]string]) {
	r.Alias = func(elem reflect.Type) []uintptr {
		return []uintptr{
			Reflect.Addr(elem),
			Reflect.Addr(reflect.SliceOf(elem)),
			Reflect.Addr(reflect.SliceOf(reflect.PtrTo(elem))),
		}
	}
})

Functions

This section is empty.

Types

type DB

type DB struct {
	*gorm.DB
	// contains filtered or unexported fields
}

func (*DB) AutoMigrate added in v0.11.4

func (db *DB) AutoMigrate(dst ...any) *DB

func (*DB) Base

func (db *DB) Base(dest any, conds ...any) *DB

func (*DB) Close added in v0.11.0

func (db *DB) Close() error

func (*DB) Error

func (db *DB) Error() error

func (*DB) First

func (db *DB) First(x any, conds ...any) bool

func (*DB) FirstOrCreate

func (db *DB) FirstOrCreate(first, create func(), x any, conds ...any)

func (*DB) NoRecord

func (db *DB) NoRecord() bool

func (*DB) Preload

func (db *DB) Preload(t any, conds ...any) *DB

func (*DB) Preloads

func (db *DB) Preloads(t any, conds ...any) *DB

func (*DB) Select added in v0.11.5

func (db *DB) Select(dest any, fields []string, conds ...any) *DB

func (*DB) SetDB

func (db *DB) SetDB(r *gorm.DB) *DB

func (*DB) SetDialector

func (db *DB) SetDialector(dialector gorm.Dialector) *DB

func (*DB) SetSqlite

func (db *DB) SetSqlite(file string) *DB

type Model

type Model struct {
	ID uint64 `gorm:"primaryKey;autoIncrement" form:"-" json:"-"`
}

type NoCopy

type NoCopy struct{}

func (*NoCopy) Lock

func (*NoCopy) Lock()

Lock is a no-op used by -copylocks checker from `go vet`.

func (*NoCopy) Unlock

func (*NoCopy) Unlock()

Jump to

Keyboard shortcuts

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