db

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Registry = []interface{}{&IdempotencyKey{}}
)

Functions

func Register

func Register(models ...interface{})

Register adds models to the global migration registry.

func RegisterDialect added in v0.2.0

func RegisterDialect(name string, provider DialectProvider)

Types

type DB

type DB struct {
	*gorm.DB
}

DB represents the database connection wrapper.

func Connect

func Connect(cfg *config.Config) (*DB, error)

Connect initializes a database connection based on the provided configuration.

func (*DB) AutoMigrateAll

func (db *DB) AutoMigrateAll() error

AutoMigrate runs the GORM AutoMigrate for all registered models.

func (*DB) IsProcessed

func (db *DB) IsProcessed(ctx context.Context, scope, key string) (bool, error)

IsProcessed checks if an operation has already been completed.

func (*DB) MarkProcessed

func (db *DB) MarkProcessed(ctx context.Context, scope, key string) error

MarkProcessed records that an operation has been completed.

func (*DB) Transaction

func (db *DB) Transaction(fn func(tx *DB) error) error

Transaction executes the given function within a database transaction.

type DialectProvider added in v0.2.0

type DialectProvider = mdk.DialectProvider

func GetDialect added in v0.2.0

func GetDialect(name string) (DialectProvider, bool)

type IdempotencyKey

type IdempotencyKey struct {
	ID        string `gorm:"primaryKey"`
	Scope     string `gorm:"index:idx_scope_key,unique"` // e.g. "workflow_step"
	Key       string `gorm:"index:idx_scope_key,unique"` // e.g. "wfID_stepID"
	CreatedAt time.Time
}

IdempotencyKey prevents duplicate processing of the same operation.

type JSONMap

type JSONMap map[string]string

JSONMap is a custom type for map[string]string that implements GORM scanner/valuer.

func (*JSONMap) Scan

func (m *JSONMap) Scan(value interface{}) error

func (JSONMap) Value

func (m JSONMap) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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