db.WriteParticipant erstellt und dazu alle IDs von int auf int64 umgestellt

This commit is contained in:
Jason Streifling 2023-10-18 16:43:04 +02:00
parent db070776b1
commit b605217625
2 changed files with 27 additions and 8 deletions

View File

@ -320,3 +320,22 @@ func (db *DB) GetInstructors() (*[]*types.Instructor, error) {
return &instructors, nil return &instructors, nil
} }
func (db *DB) WriteParticipant(p *types.Participant) error {
result, err := db.Exec(`
INSERT INTO participants
(first_name, last_name, company)
VALUES
(?, ?, ?)
`, p.FirstName, p.LastName, p.Company)
if err != nil {
return fmt.Errorf("*DB.writeParticipant: db.Exec(): %v\n", err)
}
p.ID, err = result.LastInsertId()
if err != nil {
return fmt.Errorf("*DB.writeParticipant: result.LastInsertId(): %v\n", err)
}
return nil
}

View File

@ -1,7 +1,7 @@
package types package types
type Person struct { type Person struct {
ID int ID int64
FirstName string FirstName string
LastName string LastName string
} }
@ -14,31 +14,31 @@ type Participant struct {
} }
type Briefing struct { type Briefing struct {
ID int ID int64
Date string Date string
Time string Time string
Location string Location string
DocumentName string DocumentName string
AsOf string AsOf string
InstructorID int InstructorID int64
} }
type Answer struct { type Answer struct {
ID int ID int64
Text string Text string
} }
type Question struct { type Question struct {
ID int ID int64
Text string Text string
Answers []Answer Answers []Answer
Correct int Correct int
} }
type GivenAnswer struct { type GivenAnswer struct {
BriefingID int BriefingID int64
ParticipantID int ParticipantID int64
QuestionID int QuestionID int64
GivenAnswer int GivenAnswer int
} }