Verbessere Dokumentation

This commit is contained in:
Gonne 2022-11-04 21:15:38 +01:00
parent ec24c6c4dc
commit fe54d76ab2
14 changed files with 75 additions and 34 deletions

View file

@ -1,4 +1,3 @@
// course
package repositories
import (
@ -9,6 +8,7 @@ import (
"officeHours/models"
)
// A struct to hold the db connection
type CourseRepo struct {
db *sql.DB
}
@ -38,6 +38,7 @@ func (r *CourseRepo) GetAll() ([]models.Course, error) {
return r.getFromRows(rows)
}
// Helper function to get a course from multiple SQL result rows
func (r *CourseRepo) getFromRows(rows *sql.Rows) ([]models.Course, error) {
var courses []models.Course
for rows.Next() {
@ -51,6 +52,7 @@ func (r *CourseRepo) getFromRows(rows *sql.Rows) ([]models.Course, error) {
return courses, nil
}
// Helper function to get a course from an SQL result row
func (r *CourseRepo) getFromRow(row *sql.Row) (models.Course, error) {
var course models.Course
if err := row.Scan(&course.Id, &course.Name); err != nil {