database

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGeneric = errors.New("generic database error")
View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type MongoFactory

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

func NewMongoFactory

func NewMongoFactory(client *mongo.Client, config MongoFactoryConfig) *MongoFactory

func (*MongoFactory) NewDeltaCollection added in v0.0.58

func (mf *MongoFactory) NewDeltaCollection() *mongo.Collection

func (*MongoFactory) NewSnapshotCollection

func (mf *MongoFactory) NewSnapshotCollection() *mongo.Collection

func (*MongoFactory) NewUserCollection

func (mf *MongoFactory) NewUserCollection() *mongo.Collection

type MongoFactoryConfig

type MongoFactoryConfig struct {
	DatabaseName           string
	SnapshotCollectionName string
	UserCollectionName     string
	DeltaCollectionName    string
}

type TransactionManager added in v0.0.59

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

TransactionManager handles MongoDB transactions

func NewTransactionManager added in v0.0.59

func NewTransactionManager(client *mongo.Client, transactionsEnabled bool) *TransactionManager

func (*TransactionManager) IsInTransaction added in v0.0.59

func (tm *TransactionManager) IsInTransaction(ctx context.Context) bool

IsInTransaction returns true if the context is currently within a transaction

func (*TransactionManager) WithTransaction added in v0.0.59

func (tm *TransactionManager) WithTransaction(ctx context.Context, fn func(ctx context.Context) error) error

WithTransaction executes the given function within a transaction. If transactions are disabled, it simply executes the function directly. If a transaction is already in progress (detected via context), it reuses that transaction. Otherwise, it starts a new transaction. On error, the transaction is rolled back. On success, it is committed.

Jump to

Keyboard shortcuts

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