-
Notifications
You must be signed in to change notification settings - Fork 0
/
studies.go
30 lines (25 loc) · 915 Bytes
/
studies.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package models
import (
"github.com/jmoiron/sqlx"
)
/*Studies holds all courses of study of an user. */
type Studies []Study
/*Study is a model of the studies table. */
type Study struct {
UserID int `db:"user_id, primarykey"`
Semester int `db:"semester"`
DegreeID int `db:"degree_id, primarykey"`
CourseOfStudiesID int `db:"course_of_studies_id, primarykey"`
Degree string `db:"degree"` //not a field in the studies table
CourseOfStudies string `db:"course_of_studies"` //not a field in the studies table
}
/*Select all courses of studies of a user. */
func (studies *Studies) Select(tx *sqlx.Tx, userID *int) (err error) {
err = tx.Select(studies, stmtSelectUserCoursesOfStudies, *userID)
if err != nil {
log.Error("failed to get courses of studies of user", "userID", *userID,
"error", err.Error())
tx.Rollback()
}
return
}