db

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoMigrate added in v1.4.0

func AutoMigrate(index string, dst ...interface{}) error

AutoMigrate run auto migration for given models

func ClearIndexCache added in v1.18.0

func ClearIndexCache()

ClearIndexCache clears the in-memory index height cache, intended for testing only.

func Connect

func Connect() (*gorm.DB, error)

func DB

func DB() *gorm.DB

func GetIndexHeight

func GetIndexHeight(name string) (uint64, error)

func LoadDBFromEnv added in v1.4.0

func LoadDBFromEnv() (*gorm.DB, error)

func SetDB added in v1.18.0

func SetDB(gormDB *gorm.DB)

SetDB overrides the global DB connection, intended for testing only.

func UpdateIndexHeight

func UpdateIndexHeight(name string, height uint64) error

func UpdateIndexHeightByTx

func UpdateIndexHeightByTx(tx *gorm.DB, name string, height uint64) error

Types

type BaseModel

type BaseModel struct {
	IndexName   string `gorm:"-"`
	IndexHeight uint64 `gorm:"-"`
}

type IndexHeight

type IndexHeight struct {
	ID     uint32 `gorm:"primary_key;auto_increment"`
	Name   string `gorm:"size:128;not null;unique"`
	Height uint64 `sql:"type:bigint"`
}

func (*IndexHeight) ByName

func (m *IndexHeight) ByName(name string) (*IndexHeight, error)

type Store

type Store struct {
	ID       uint32 `gorm:"primary_key;auto_increment"`
	Key      string `gorm:"size:128;not null;unique"`
	Value    string `sql:"type:json"`
	CreateAt time.Time
	UpdateAt time.Time
}

func (*Store) Get added in v1.8.41

func (s *Store) Get() error

func (*Store) Save

func (s *Store) Save() error

func (Store) TableName

func (Store) TableName() string

Jump to

Keyboard shortcuts

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