orm

package
v1.10.49 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBInfoSchema = struct {
	TableName     string
	ID            string
	CreatedAt     string
	UpdatedAt     string
	SchemaVersion string
}{}
View Source
var LogSchema = struct {
	TableName string
	ID        string
	CreatedAt string
	UpdatedAt string
	Level     string
	Source    string
	Msg       string
}{}

Functions

func UpdateSchema

func UpdateSchema(db *gorm.DB, st *common.StringTable, model any, schema any) (string, error)

Types

type DBInfo

type DBInfo struct {
	ID            int       `json:"id" desc:"Unique database ID"`
	CreatedAt     time.Time `json:"createdAt" gorm:"index" desc:"Timestamp this DB record has been created"`
	UpdatedAt     time.Time `json:"updatedAt" gorm:"index" desc:"Timestamp this DB record has been updated the last time"`
	SchemaVersion int       `json:"schemaVersion" desc:"Database schema version"`
}

type Log

type Log struct {
	ID        sqldb.FieldInt64  `json:"id" desc:"Unique database ID"`
	CreatedAt sqldb.FieldTime   `json:"createdAt" gorm:"index" desc:"Timestamp this DB record has been created"`
	UpdatedAt sqldb.FieldTime   `json:"updatedAt" gorm:"index" desc:"Timestamp this DB record has been updated"`
	Level     sqldb.FieldString `json:"level" gorm:"index" desc:"level"`
	Source    sqldb.FieldString `json:"source" gorm:"index" desc:"source"`
	Msg       sqldb.FieldString `json:"msg" desc:"msg"`
}

type MigrateFunc

type MigrateFunc func(gormDB *gorm.DB, schemaVersion int) error

type ORM

type ORM struct {
	SchemaVersion int
	SchemaModels  []ORMSchemaModel
	Gorm          *gorm.DB
	// contains filtered or unexported fields
}

func NewORM

func NewORM(driver ORMDriver, schemaVersion int, schemaModels []ORMSchemaModel) (*ORM, error)

func (*ORM) Close

func (orm *ORM) Close() error

func (*ORM) Health

func (orm *ORM) Health() error

func (*ORM) Prepare

func (orm *ORM) Prepare(setupFunc SetupFunc, migrateFunc MigrateFunc) error

func (*ORM) Reset

func (orm *ORM) Reset() error

func (*ORM) Synchronized

func (orm *ORM) Synchronized(fn func() error) error

func (*ORM) VerifyCfgChanged

func (orm *ORM) VerifyCfgChanged(cfg any) error

type ORMDriver

type ORMDriver interface {
	Dialector() gorm.Dialector
	Synchronized(*sql.DB, func() error) error
}

type ORMSchemaModel

type ORMSchemaModel struct {
	Model       any
	Schema      any
	CanTruncate bool
}

type SetupFunc

type SetupFunc func(gormDB *gorm.DB) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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