Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #25 from palavrapasse/24-refactor-return-leak-id-i…
Browse files Browse the repository at this point in the history
…n-the-insert

refactor: return leak id in the insert
  • Loading branch information
rutesantos4 committed Jan 23, 2023
2 parents e805ef3 + 5e2e1b3 commit 4e1669c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (ctx DatabaseContext[R]) NewTransactionContext() (TransactionContext[R], er
return TransactionContext[R]{Tx: tx}, err
}

func (ctx DatabaseContext[Record]) Insert(i Import) error {
func (ctx DatabaseContext[Record]) Insert(i Import) (AutoGenKey, error) {

var tx *sql.Tx

Expand All @@ -75,6 +75,8 @@ func (ctx DatabaseContext[Record]) Insert(i Import) error {
}
}()

var leakId AutoGenKey

func() {
us := make([]User, len(i.AffectedUsers))
cr := make([]Credentials, len(i.AffectedUsers))
Expand Down Expand Up @@ -125,6 +127,7 @@ func (ctx DatabaseContext[Record]) Insert(i Import) error {
ps := pts[4].(PrimaryTable[Platform]).Records

l := ls[0]
leakId = l.LeakId
afu := map[User]Credentials{}

for k := range us {
Expand Down Expand Up @@ -166,7 +169,7 @@ func (ctx DatabaseContext[Record]) Insert(i Import) error {
err = tx.Commit()
}

return err
return leakId, err
}

func (ctx DatabaseContext[Record]) InsertSubscription(s Subscription) error {
Expand Down

0 comments on commit 4e1669c

Please sign in to comment.