Comments (4)
In my project I have this code
func Transaction(db *bun.DB, callback func(tx bun.Tx) error) error {
tx, err := db.Begin()
if err != nil {
return err
}
err = callback(tx)
if err != nil {
if rErr := tx.Rollback(); rErr != nil {
return rErr
}
return err
}
return tx.Commit()
}
from bun.
That looks good. What do you think about also accepting TxOptions
?
Also the code should probably use defer tx.Rollback()
to better handle panics.
from bun.
Added in v0.2.5
from bun.
That looks good. What do you think about also accepting
TxOptions
?Also the code should probably use
defer tx.Rollback()
to better handle panics.
Good ideas.
from bun.
Related Issues (20)
- When will pgdialect support multidimensional array ?
- Document: Using a Relation to select a null column returns a nil pointer
- Using Bun with pgxpool.Pool
- DatabaseTypeName missing with pgdriver
- Create temp table from select query
- Has Many Join on nullable value HOT 7
- When the original SQL query and scan are used, there will be garbled characters.
- model tag "alt" don't work HOT 1
- nullzero relations not being fetched HOT 2
- Multiple joins not deserializing correctly
- TrunateTableQuery: missing ModelTableExpr() method
- Postgres update join not working HOT 1
- How to handle logical names of columns that are too long? HOT 1
- Model() w/o params in doc?
- [bug] Query Select uses wrong table name when ModelTableExpr is called HOT 2
- I want to be able to use PostgreSQL's parametric placeholders.
- inconsistent behavior for ModelTableExpr (select <--> create/insert/update/delete)
- race detected in ```schema.Field.Clone()``` HOT 2
- Issue with BeforeAppendModel when selecting columns to update HOT 1
- Go migrations are not discovered
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bun.