diff options
Diffstat (limited to 'persistence/sqlite/sqliteRepository.go')
-rw-r--r-- | persistence/sqlite/sqliteRepository.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/persistence/sqlite/sqliteRepository.go b/persistence/sqlite/sqliteRepository.go index 9e0e3f5..76ac46f 100644 --- a/persistence/sqlite/sqliteRepository.go +++ b/persistence/sqlite/sqliteRepository.go @@ -46,6 +46,14 @@ func (repo *sqliteRepository) SaveRegistration(registration *registration.Regist return err } +func rowToRegistration(scanner interface{ Scan(dest ...any) error }) (*registration.Registration, error) { + var reg registration.Registration + err := scanner.Scan(®.RegId, ®.FirstName, ®.LastName, ®.Email, ®.Company, ®.TrainingCode, ®.Date, ®.PrivacyPolicyAccepted) + if err != nil { + return nil, err + } + return ®, nil +} func (repo *sqliteRepository) GetUnconfirmedRegistrations() ([]*registration.Registration, error) { db, err := repo.checkInit() @@ -66,12 +74,11 @@ func (repo *sqliteRepository) GetUnconfirmedRegistrations() ([]*registration.Reg regArray := make([]*registration.Registration, 0) for res.Next() { - reg := registration.Registration{} - err = res.Scan(®.RegId, ®.FirstName, ®.LastName, ®.Email, ®.Company, ®.TrainingCode, ®.Date, ®.PrivacyPolicyAccepted) + reg, err := rowToRegistration(res) if err != nil { log.Printf("Error scanning: %v", err) } - regArray = append(regArray, ®) + regArray = append(regArray, reg) } return regArray, nil } |