summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--persistence/sqlite/sqliteRepository.go13
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(&reg.RegId, &reg.FirstName, &reg.LastName, &reg.Email, &reg.Company, &reg.TrainingCode, &reg.Date, &reg.PrivacyPolicyAccepted)
+ if err != nil {
+ return nil, err
+ }
+ return &reg, 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(&reg.RegId, &reg.FirstName, &reg.LastName, &reg.Email, &reg.Company, &reg.TrainingCode, &reg.Date, &reg.PrivacyPolicyAccepted)
+ reg, err := rowToRegistration(res)
if err != nil {
log.Printf("Error scanning: %v", err)
}
- regArray = append(regArray, &reg)
+ regArray = append(regArray, reg)
}
return regArray, nil
}