Documentation
¶
Index ¶
- Variables
- func Caller(skip int) (file string)
- func Close() error
- func Exists[T any](conds ...any) bool
- func Find[T any, V any](conds ...any) (dest []T, v V)
- func First[T any, V any](conds ...any) (*T, V)
- func FirstOrCreate[T any](x *T, conds ...any) caller
- func Found(err error) bool
- func Link(relative string)
- func MustFind[T any](conds ...any) (dest []T)
- func MustFirst[T any](conds ...any) (dest *T)
- func MustPreload[T any](conds ...any) (dest *T)
- func MustPreloads[T any](conds ...any) (dest []T)
- func Preload[T any, V any](conds ...any) (*T, V)
- func Preloads[T any, V any](conds ...any) (dest []T, v V)
- type DB
- func AutoMigrate(dst ...any) *DB
- func Get() *DB
- func NewDB(file string, gormDB *gorm.DB) *DB
- func Relative(elem string) *DB
- func Select(fields ...string) *DB
- func SetDialector(dialector gorm.Dialector, opts ...gorm.Option) *DB
- func SetGormDB(gormDB *gorm.DB) (db *DB)
- func SetSQLite(file string, opts ...gorm.Option) *DB
- func (db *DB) AutoMigrate(dst ...any) *DB
- func (db *DB) Clone() *DB
- func (db *DB) Close() error
- func (db *DB) Debug() *DB
- func (db *DB) Do(fn func(db *DB)) *DB
- func (db *DB) Error() error
- func (db *DB) File() string
- func (db *DB) Find(dest any, conds ...any) *DB
- func (db *DB) FindOK(dest any, conds ...any) bool
- func (db *DB) First(dest any, conds ...any) *DB
- func (db *DB) FirstOK(dest any, conds ...any) bool
- func (db *DB) FirstOrCreate(x any, conds ...any) caller
- func (db *DB) Found() bool
- func (db *DB) GetInstance(r *gorm.DB) *DB
- func (db *DB) PkgPath() string
- func (db *DB) Preload(t any, conds ...any) *DB
- func (db *DB) PreloadOK(t any, conds ...any) bool
- func (db *DB) PreloadType(in any, m map[string][]any) (tx *DB)
- func (db *DB) Preloads(t any, conds ...any) *DB
- func (db *DB) PreloadsOK(t any, conds ...any) bool
- func (db *DB) Select(fields ...string) (tx *DB)
- func (db *DB) Succeed() bool
- type Manager
- type Model
- type Parser
Constants ¶
This section is empty.
Variables ¶
View Source
var GlobalDB = make(Manager)
View Source
var Ref = Reflect.NewMap[Parser, []string](114514, Reflect.SLICEPTRALIAS)
Functions ¶
func Caller ¶
Caller returns the file path where this function is called.
The `skip` parameter has a default value 1.
func FirstOrCreate ¶
func Link ¶
func Link(relative string)
Link links the DB represented by the relative path to the caller path.
func MustPreload ¶
func MustPreloads ¶
Types ¶
type DB ¶
Superset of gorm.DB
func AutoMigrate ¶
func (*DB) AutoMigrate ¶
func (*DB) Close ¶
Close fetch the original sql.DB and attempt to close it.
It returns nil if the DB has been closed successfully.
Otherwise an error will be returned.
func (*DB) FirstOrCreate ¶
type Model ¶
type Model[T constraints.Integer] struct { ID T `gorm:"primaryKey;autoIncrement" json:"id" yaml:"id" form:"id"` }
Click to show internal directories.
Click to hide internal directories.