database

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec added in v0.3.0

func Exec(ctx context.Context, db *sqlx.DB) sqlx.ExtContext

Types

type DB added in v0.3.0

type DB struct {
	// contains filtered or unexported fields
}

DB is the repo-facing handle. It has the full query surface + WithinTx.

func (*DB) ExecContext added in v0.3.0

func (d *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*DB) GetContext added in v0.3.0

func (d *DB) GetContext(ctx context.Context, dest any, query string, args ...any) error

func (*DB) NamedExecContext added in v0.3.0

func (d *DB) NamedExecContext(ctx context.Context, query string, arg any) (sql.Result, error)

func (*DB) QueryRowxContext added in v0.3.0

func (d *DB) QueryRowxContext(ctx context.Context, query string, args ...any) *sqlx.Row

func (*DB) QueryxContext added in v0.3.0

func (d *DB) QueryxContext(ctx context.Context, query string, args ...any) (*sqlx.Rows, error)

func (*DB) Rebind added in v0.3.0

func (d *DB) Rebind(query string) string

Rebind translates `?` placeholders to whatever the underlying driver expects. Lets callers compose queries via sqlx.In (e.g. `WHERE id IN (?)`) without having to think about driver-specific bind styles.

func (*DB) SelectContext added in v0.3.0

func (d *DB) SelectContext(ctx context.Context, dest any, query string, args ...any) error

func (*DB) WithinTx added in v0.3.0

func (d *DB) WithinTx(ctx context.Context, fn func(context.Context) error) error

WithinTx available on DB so repos can scope their OWN atomic flows.

type DBTime

type DBTime struct {
	time.Time
}

DBTime is only needed for aggregate functions (MAX, MIN etc.) that return TEXT even for DATETIME columns. Regular columns declared as DATETIME scan directly into time.Time when using modernc.org/sqlite with _texttotime=1 in the DSN.

func (*DBTime) Scan

func (t *DBTime) Scan(value any) error

func (DBTime) Value

func (t DBTime) Value() (driver.Value, error)

type SQLite

type SQLite struct {
	// contains filtered or unexported fields
}

func NewSQLite

func NewSQLite(dbConf config.ConfDB) (*SQLite, error)

func (*SQLite) Close

func (s *SQLite) Close() error

func (*SQLite) DB

func (s *SQLite) DB() *DB

func (*SQLite) Migrate

func (s *SQLite) Migrate() error

func (*SQLite) Transactor added in v0.3.0

func (s *SQLite) Transactor() *Transactor

type Transactor added in v0.3.0

type Transactor struct {
	// contains filtered or unexported fields
}

Transactor is the service-facing handle. It exposes ONLY tx orchestration — no query methods. A service holding one can compose operations atomically but cannot perform SQL.

func NewTransactor added in v0.3.0

func NewTransactor(pool *sqlx.DB) *Transactor

func (*Transactor) WithinTx added in v0.3.0

func (t *Transactor) WithinTx(ctx context.Context, fn func(context.Context) error) error

Jump to

Keyboard shortcuts

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