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

Commit

Permalink
return leak id in the insert
Browse files Browse the repository at this point in the history
  • Loading branch information
rutesantos4 committed Jan 23, 2023
1 parent e805ef3 commit 5e2e1b3
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 5e2e1b3

Please sign in to comment.