database

package module
v0.0.0-...-98a3319 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

README

database

Database helper

Documentation

Index

Constants

View Source
const MaxAttempts = 1_000_000

Variables

View Source
var ErrMaxAttemptsExceeded = errors.New("max numbers of attempts exceeded")

Functions

func CreateBatchSize

func CreateBatchSize[T any](c *Connection) (size int, err error)

Types

type Config

type Config struct {
	Logger           *slog.Logger
	DSN              string      `yaml:"dsn"`
	ConnectionConfig gorm.Config `yaml:"-"`
}

type Connection

type Connection struct {
	Driver             DriverName
	TransactionCounter atomic.Int64
	Logger             *slog.Logger
	*gorm.DB
}

func SQLite

func SQLite(config Config) (conn *Connection, err error)

Easier local testing Database. Should not be used in production.

func (*Connection) Close

func (conn *Connection) Close() (err error)

func (*Connection) Transaction

func (c *Connection) Transaction(ctx context.Context, fc func(tx *gorm.DB) (err error), opts ...*sql.TxOptions) (err error)

type DriverName

type DriverName string
const DriverNameSQLite DriverName = "sqlite"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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