Still migrating to postgres, have to check that everything works and fix stuff
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
package expenses
|
||||
|
||||
import (
|
||||
"context"
|
||||
mod "expenses/expenses/models"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
func (a *ExpensesApp) GetAllUsers() ([]mod.User, error) {
|
||||
tx, err := a.DB.Begin()
|
||||
ctx := context.Background()
|
||||
tx, err := a.DB.BeginTx(ctx, pgx.TxOptions{})
|
||||
if err != nil {
|
||||
return []mod.User{}, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
users, err := mod.GetAllUsers(tx)
|
||||
users, err := mod.GetAllUsers(a.DB, tx)
|
||||
if err != nil {
|
||||
return []mod.User{}, err
|
||||
}
|
||||
|
||||
return users, tx.Commit()
|
||||
|
||||
return users, tx.Commit(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user