db

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*drel.Engine
	Articles *articles.ArticleRepository
}

func Open

func Open(dsn string, opts ...drel.Option) (*DB, error)

func (*DB) Tx added in v0.6.0

func (db *DB) Tx(ctx context.Context) TxRepos

Tx returns the tracked repositories bound to the transaction in ctx. It panics if no transaction is present, so wrap the call in WithTx.

func (*DB) WithTx added in v0.6.0

func (db *DB) WithTx(ctx context.Context, fn func(ctx context.Context) error, opts ...drel.TxOption) error

WithTx runs fn inside a transaction and puts that transaction in the context it passes to fn. Reach the tracked repositories with db.Tx(ctx). A nested call opens a savepoint on the same transaction.

type TxRepos added in v0.6.0

type TxRepos struct {
	Articles *articles.TxArticleRepository
}

TxRepos holds the tracked repositories of one transaction. Load through the fields, stage with Add and Remove, then let WithTx commit.

Jump to

Keyboard shortcuts

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