VladimirStepanov / pgxtransactor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is that?

pgxtransactgor is a library for using a common transaction connection between repository method calls

How to use it?

//...
txManager.RunRepeatableRead(ctx, func(dbCtx context.Context) error {
    product, err := repo.GetProduct(dbCtx, 1)
    if err != nil {
        return err
    }
    // some data processing
    product.Price += 10000
    return repo.UpdateProduct(dbCtx, product)
})

Full example in ./example directory

About


Languages

Language:Go 100.0%