1
0
Fork 0

refactor: repository pattern: rename Save() to Create()

This commit is contained in:
Vojtěch Mareš 2024-04-30 21:37:59 +02:00
parent ab4226561b
commit cb9cc47245
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
8 changed files with 8 additions and 8 deletions

View file

@ -76,7 +76,7 @@ func (r *AttendeeRepository) CountForDate(dateID training.DateID) (int, error) {
return count, nil
}
func (r *AttendeeRepository) Save(a *training.Attendee) error {
func (r *AttendeeRepository) Create(a *training.Attendee) error {
_, err := r.db.Exec("INSERT INTO attendee (id, date_id, name, email, company, role, is_student, has_attended, has_paid) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", a.ID, a.DateID, a.Name, a.Email, a.Company, a.Role, a.IsStudent, a.HasAttended, a.HasPaid)
return err
}

View file

@ -68,7 +68,7 @@ func (r *DateRepository) FindAllForTraining(id training.ID) ([]training.Date, er
return dates, nil
}
func (r *DateRepository) Save(d *training.Date) error {
func (r *DateRepository) Create(d *training.Date) error {
_, err := r.db.Exec("INSERT INTO date (id, date, training_id, start_time, days, price, is_online, location, address, capacity) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", d.ID, d.Date, d.TrainingID, d.StartTime, d.Days, d.Price, d.IsOnline, d.Location, d.Address, d.Capacity)
return err
}

View file

@ -45,7 +45,7 @@ func (r *FeedbackRepository) FindAll() ([]training.Feedback, error) {
return feedbacks, nil
}
func (r *FeedbackRepository) Save(f *training.Feedback) error {
func (r *FeedbackRepository) Create(f *training.Feedback) error {
_, err := r.db.Exec("INSERT INTO feedback (id, attendee_id, rating, comment, is_anonymous, is_sharing_allowed) VALUES ($1, $2, $3, $4, $5, $6)", f.ID, f.AttendeeID, f.Rating, f.Comment, f.IsAnonymous, f.IsSharingAllowed)
return err
}

View file

@ -14,7 +14,7 @@ func NewTrainingRepository(db *sql.DB) *TrainingRepository {
return &TrainingRepository{db: db}
}
func (r *TrainingRepository) Save(t *training.Training) error {
func (r *TrainingRepository) Create(t *training.Training) error {
_, err := r.db.Exec("INSERT INTO training (id, name, days, description, price) VALUES ($1, $2, $3)", t.ID, t.Name, t.Days, t.Description, t.Price)
return err
}