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 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.
Click to show internal directories.
Click to hide internal directories.