result in db transactions added
This commit is contained in:
parent
36fb1906ba
commit
50e9c625be
@ -21,6 +21,7 @@ type Database struct {
|
||||
|
||||
type Transaction struct {
|
||||
tx *sql.Tx
|
||||
res Record
|
||||
err error
|
||||
}
|
||||
|
||||
@ -287,7 +288,8 @@ func (d *Database) UserVersion() (int64, error) {
|
||||
|
||||
func (d *Database) Begin() *Transaction {
|
||||
tx, err := d.database.Begin()
|
||||
return &Transaction{tx, err}
|
||||
res := Record{}
|
||||
return &Transaction{tx, res, err}
|
||||
}
|
||||
|
||||
func (t *Transaction) Next(action Action) *Transaction {
|
||||
@ -298,17 +300,17 @@ func (t *Transaction) Next(action Action) *Transaction {
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *Transaction) End() error {
|
||||
func (t *Transaction) End() (Record, error) {
|
||||
|
||||
if t.err != nil {
|
||||
err := t.tx.Rollback()
|
||||
if err != nil {
|
||||
t.err = errors.Join(t.err, err)
|
||||
}
|
||||
return t.err
|
||||
return t.res, t.err
|
||||
}
|
||||
t.err = t.tx.Commit()
|
||||
return t.err
|
||||
return t.res, t.err
|
||||
}
|
||||
|
||||
func (t *Transaction) GetRecord(tablename string, idfield string, key any, output Record) *Transaction {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user